I\'d like to collect stacktraces from my Java app for creating CPU Flame Graphs for profiling.
This is very similar to this question: How to get complete stack dump from
I created 2 little shell scripts based on @cello's answer. They generate hot/cold flame graphs.
Get them from this Gist.
Usage:
ps ax | grep java # find the PID of your process
./profile.sh 20402 stacks.txt
./gen.sh stacks.txt
Alternatively, to measure application from startup (in this, case, my gradle build that also needed to be run in another directory and with some input stream) I used:
cd ../my-project; ./gradlew --no-daemon clean build < /dev/zero &; cd -; ./profile.sh $! stacks.txt
./gen.sh stacks.txt
Results:
In this example, I can clearly see that my application is I/O bound (notice blue bars on top).