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

前端 未结 5 1229
无人共我
无人共我 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:44

    First of all, it is (AFAIK) essential to freeze the JVM while a thread dump / snapshot is being taken. If JVM was able to continue running while the snapshot was created, it would be next to impossible to get a coherent snapshot.

    So are there other ways to get a heap dump?

    • You can get a heap dump using VisualVM as described here.

    • You can get a heap dump using jconsole or Eclipse Memory Analyser as described here.

    But all of these are bound to cause the JVM to (at least) pause.


    If your application is actually hanging (permanently!) that sounds like a problem with your application itself. My suggestion would be to see if you can track down that problem before looking for the storage leak.

    My other suggestion is that you look at a single heap dump, and use the stats to figure out what kind(s) of object are using all of the space ... and why they are reachable. There is a good chance that you don't need the "trend" information at all.

提交回复
热议问题