none
[Java][Web Apps] Generate a Java heap dump RRS feed

Answers

  • As I known, there are two common ways to get the JVM heap dump file as below.

    1. Command "jmap -dump:format=b,file=<dump-filename>.hprof <java pid>"

    2. Add the JVM arguments for java startup. Option "-XX:+HeapDumpOnOutOfMemoryError" enables heap dumps when an OutOfMemoryError occurs. And option "-XX:HeapDumpPath=<path>" specify the dump location, that default location for the dump file is the current working directory.

    I tried to do via the first way in the Kudu Console, but I could not get the java pid thru command "ps" in CMD or "Get-Process" in PowerShell, even Java command "jps -l -m".

    So I think you can try to generate a Java heap dump using the second way via set up the "environmentVariable" in the "web.config" file for your app service, please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples.

    <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath={path}" />

    For analysing the heap dump, you can use "jhat" tool by refering to http://docs.oracle.com/javase/7/docs/technotes/tools/share/jhat.html.

    Or the GUI tool of Eclipse Memory Analyzer (MAT, https://www.eclipse.org/mat/) is better choice for UX.

    Hope it helps.

    Best Regards.


    Friday, February 5, 2016 4:20 AM
    Moderator
  • Hi,

    You can try to deploy "PSI Probe" in your web app for monitoring tomcat, please see https://github.com/psi-probe/psi-probe.

    Best Regards.

    Monday, February 8, 2016 2:22 AM
    Moderator

All replies

  • As I known, there are two common ways to get the JVM heap dump file as below.

    1. Command "jmap -dump:format=b,file=<dump-filename>.hprof <java pid>"

    2. Add the JVM arguments for java startup. Option "-XX:+HeapDumpOnOutOfMemoryError" enables heap dumps when an OutOfMemoryError occurs. And option "-XX:HeapDumpPath=<path>" specify the dump location, that default location for the dump file is the current working directory.

    I tried to do via the first way in the Kudu Console, but I could not get the java pid thru command "ps" in CMD or "Get-Process" in PowerShell, even Java command "jps -l -m".

    So I think you can try to generate a Java heap dump using the second way via set up the "environmentVariable" in the "web.config" file for your app service, please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples.

    <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath={path}" />

    For analysing the heap dump, you can use "jhat" tool by refering to http://docs.oracle.com/javase/7/docs/technotes/tools/share/jhat.html.

    Or the GUI tool of Eclipse Memory Analyzer (MAT, https://www.eclipse.org/mat/) is better choice for UX.

    Hope it helps.

    Best Regards.


    Friday, February 5, 2016 4:20 AM
    Moderator
  • Hi,

    Thanks you for your answer, but I need to do a dump of memory during the life of the process to track memory leak and other stuffs, not when the process died.

    How could I do it with Microsoft Azure in webapp mode ?

    Best regards,

    Friday, February 5, 2016 10:04 AM
  • Hi,

    You can try to deploy "PSI Probe" in your web app for monitoring tomcat, please see https://github.com/psi-probe/psi-probe.

    Best Regards.

    Monday, February 8, 2016 2:22 AM
    Moderator
  • Thanks you for your answer, but I will prefer to not change the tomcat installed by Azure. I won't get in specific option not provided directly by Azure and supported by it.

    Friday, February 12, 2016 5:24 PM