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

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

    A heap dump analyzed with the right tool will tell you exactly what is consuming the heap. It is the best tool for tracking down memory leaks. However, collecting a heap dump is slow let alone analyzing it.

    With knowledge of the workings of your application, sometimes a histogram is enough to give you a clue of where to look for the problem. For example, if MyClass$Inner is at the top of the histogram and MyClass$Inner is only used in MyClass, then you know exactly which file to look for a problem.

    Here's the command for collecting a histogram.

    jcmdpidGC.class_histogram filename=histogram.txt

提交回复
热议问题