How to get Java profiling dump for creating flame graphs on the mac?

前端 未结 4 1485
一个人的身影
一个人的身影 2021-02-04 15:45

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

4条回答
  •  一生所求
    2021-02-04 16:24

    Did you try the jstack command? just run it on the command line: jstack pidOfJavaProcess > stack.txt (naturally, replacing pidOfJavaProcess with the actual process number). You could run this in a loop in bash (the default shell used on Mac OS X):

    while true; do jstack pidOfJavaProcess >> stack.txt; sleep 1.0; done
    

    note the >> to append to the file, and not overwrite it each second. Press Ctrl+C to stop logging the stack traces.

    This will only generate the java stack traces, and not the native call stacks from the JVM.

提交回复
热议问题