Why is my Java heap dump size much smaller than used memory?

 ̄綄美尐妖づ 提交于 2019-11-30 08:58:15
Brandon

When dumping its heap, the JVM will first run a garbage collection cycle to free any unreachable objects.

How can I take a heap dump on Java 5 without garbage collecting first?

In my experience, in a true OutOfMemoryError where your application is simply demanding more heap space than is available, this GC is a fool's errand and the final heap dump will be the size of the max. heap size.

When the heap dump is much smaller, that means the system was not truly out of memory, but perhaps had memory pressure. For example, there is the java.lang.OutOfMemoryError: GC overhead limit exceeded error, which means that the JVM may have been able to free enough memory to service some new allocation request, but it had to spend too much time collecting garbage.

It's also possible that you don't have a memory problem. What makes you think you do? You didn't mention anything about heap usage or an OutOfMemoryError. You've only mentioned the JVM's memory footprint on the operating system.

In my experience, having a heap dump much smaller than the real memory used can be due to a leak in the JNI.

Despite you don't use directly any native code, there are certain libraries that use it to speed up.

In our case, it was a Deflater and Inflater not properly ended.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!