I'm trying to generate a Flame Graph for a Java program, using perf-map-agent. I know that you can use perf-java-record-stack
to record data for a running process. I have also found out that you may use the script jmaps
in the Flame Graph directory. I have found Brendan Gregg's example as well as a Stack Overflow post illustrating this. However, in none of these examples the Java process is given as an argument to perf record
(which means that perf collects stack traces for the entire system).
I want to record profiling data for the whole execution of the program (and preferably nothing else). Is there any way to do this? I have tried:
perf record -a -g java -XX:+PreserveFramePointer <other JVM arguments> <my java program>; sudo ~/bin/brendangregg/FlameGraph/jmaps
which answers:
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.711 MB perf.data (3449 samples) ]
Fetching maps for all java processes...
Mapping PID 2213 (user malin):
wc(1): 2970 9676 156108 /tmp/perf-2213.map
always with the same PID. This PID is a running process, not the one I tried to record data for.