Profiling a running Java application in command line

前端 未结 7 1213
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 11:37

I profile running Java applications often with VisualVM but it needs X to run on the machine.

I know I can connect through management port but that will be an offlin

7条回答
  •  感情败类
    2020-12-23 11:46

    The jvmtop application is a convenient tool for profiling from the commandline. No need to stop the jvm. Usage:

    jvmtop.sh --profile 
    

    Will give you output like this which will be updating while the app runs:

      Profiling PID 24015: org.apache.catalina.startup.Bootstrap
      36.16% (    57.57s) hudson.model.AbstractBuild.calcChangeSet()
      30.36% (    48.33s) hudson.scm.SubversionChangeLogParser.parse()
       7.14% (    11.37s) org.kohsuke.stapler.jelly.JellyClassTearOff.parseScript()
      ...
    

    The advantage is that it does not take the use of instrumentation. The classes of the to-be-profiled jvm will not be altered.

    If you are looking for something more visual then have a look at jvm-mon which is based on jvmtop

提交回复
热议问题