With VisualVM, I can connect to the local Java process, start / stop CPU profiling, and create a snapshot. I don’t even need to process the process using any special agents, etc.
Is it possible to do the same thing on a server without a head? I know that I can configure the process for debugging the debugger remotely, but I want to minimize the number and impact of changing the client environment. I just want to run the command in the profile for a while and generate a snapshot file that I can run scp for my workstation for analysis using VisualVM or equivalent.
Preferably, any program that I run for this should be freely distributed so that I can associate it with my Java application and have it in a client environment.
Ideally, as in VisualVM, I would like to be able to connect to a running system without rebooting.
The closest I have found so far is related to hprof :
java -agentlib:hprof=cpu=samples,interval=20,depth=3 classname
but this requires a restart in order to start profiling, and the other to stop, because I don’t see a way to enable and disable the selection at runtime.
Is there a better way? If there is no ready-made solution, how to build it? This should be possible since VisualVM does this.
source
share