Can JVisualVM “Heap Dump” button release memory?

那年仲夏 提交于 2019-12-01 05:47:34

Can "Heap Dump" operation release almost 200 mbs? If yes, WHY?

Yes it can. I haven't studied the code but I am pretty sure it calls HotSpotDiagnosticMXBean.dumpHeap with the second argument set to true (it is the default if you call it form jconsole or the MBeans extension to JVisualVM). In my experience, doing so will trigger an explicit gc before it dumps the heap and that is probably the answer to the "Why?".

Tomasz Nurkiewicz

Why are you even bothered by GC? If the memory is properly released, there is no need to worry. But if you want to discover what causes heap to grow (even thou it's not a leak), look at this: How can I take a heap dump on Java 5 without garbage collecting first?.

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