Finding Java memory leak when not all used heap is reachable from threads

后端 未结 5 914
醉话见心
醉话见心 2021-02-18 15:52

I am looking into a potential memory leak (or at least memory waste) in a largish Java based system. The JVM is running with a maximum heap size of 5 GB and 2-3GB heap usage is

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-18 16:49

    Use JProfiler and break the heap object count down by class - find which class has lots of instances and start your hunt there.

    You can also take a couple of snapshots a short time apart and compare the two heap dumps to see what objects were created during that time. This is particularly handy if you know that a certain action is causing the problem and you want to ignore all the background JVM object noise and just examine the delta.

    I have used it with great success to find a memory leak. It isn't free, but it's worth the licence fee.

    FYI: I have no affiliation with JProfiler.

提交回复
热议问题