Where is my Java memory going?

2019-06-01 19:28发布

I am running a JUnit test suite from Ant or Eclipse. PermGen is limited to 200 MB, heap to 1000 MB.

Java VisualVM reports allocated PermGen as 200 MB and allocated heap as 350 MB. That's 550 MB.

However, total virtual set size of this process is 2.5 GB, and resident set size is 1.8 GB. I understand there is supposed to be some overhead, but if PermGen and heap are 0.5 GB and the process is using 1.8 GB, where is the missing 1.3 GB? How can I diagnose and fix it?

2条回答
迷人小祖宗
2楼-- · 2019-06-01 20:18

What is the heap free ratio? Are you using the default 70 and 40%. Maybe, there are garbage objects waiting to be collected by the next gc run. Also maybe the java process has allocated itself the extra memory (read about the heap free ratio).

Maybe the question/ answer/ comments mentioned at Tuning Garbage Collection parameters in Java offer some help.

查看更多
仙女界的扛把子
3楼-- · 2019-06-01 20:18

Please check this eclipse plugin for memory analysis . Once you have installed this, it offers different views. In one particular view, its shows the memory used by individual objects. This will help you to pinpoint the objects which are using the memory.

EDIT: I guess I missed the non-heap part.

查看更多
登录 后发表回答