How do I produce a heap dump with only a JRE?

后端 未结 4 1856
抹茶落季
抹茶落季 2020-12-31 04:32

We have a JRE installed on our production environment, but not a JDK. The versions of the JRE and OS are below.

[me@mymachine ~]$ java -version
java version &         


        
相关标签:
4条回答
  • 2020-12-31 04:52

    Built-in tools like jmap, jconsole, and jvisualvm are only available in a JDK. Another option is to add the VM argument -XX:+HeapDumpOnOutOfMemoryError which tells the JVM to automatically generate a heap dump when an OutOfMemoryError occurs, and the argument -XX:HeapDumpPath to specify the path for the heap dump.

    If you cannot upgrade your JRE to use tools like the ones in the server JRE 7 (http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html), you may have to consider third-party profiling tools like JProfiler or ones list here.

    0 讨论(0)
  • 2020-12-31 05:03
     kill -3 <pid>
    

    thread dump will be sent in to <TOMCAT_HOME>/logs/catalina.out file

    OR use combination below :

    -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=~/jvm.log
    

    if you want to redirect., but for that you have to run your process through command line.

    0 讨论(0)
  • 2020-12-31 05:09

    The only way seems to be to zip your local SDK6 and put it somewhere on the server. Then open a remote console and from within the bin directory of that SDK dump the JRE.

    If your client forbids uploading executable files, you are out of luck of course.

    0 讨论(0)
  • 2020-12-31 05:10

    Use jattach, a tool created by JVM hacker Andrei Pangin. It's tiny (24KB), works with just JRE and supports Linux containers.

    jattach PID-OF-JAVA dumpheap <path to heap dump file>

    0 讨论(0)
提交回复
热议问题