Java : Get heap dump without jmap or without hanging the application

前端 未结 5 1220
无人共我
无人共我 2021-01-05 03:15

In few circumstance, our application is using around 12 GB of memory. We tried to get the heap dump using jmap utility. Since the application is using some GB of memory it c

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 03:48

    Try the following. It comes with JDK >= 7:

    /usr/lib/jvm/jdk-YOUR-VERSION/bin/jcmd PID GC.heap_dump FILE-PATH-TO-SAVE
    

    Example:

    /usr/lib/jvm/jdk1.8.0_91/bin/jcmd 25092 GC.heap_dump /opt/hd/3-19.11-jcmd.hprof
    

    This dumping process is much faster than dumping with jmap! Dumpfiles are much smaller, but it's enough to give your the idea, where the leaks are.

    At the time of writing this answer, there are bugs with Memory Analyzer and IBM HeapAnalyzer, that they cannot read dumpfiles from jmap (jdk8, big files). You can use Yourkit to read those files.

提交回复
热议问题