问题描述
我有一个非常奇怪的问题。我正在开发一个基于Eclipse Equinox的OSGi应用程序;它是使用OSGi Log Service(Equinox实现)开发的,现在我正在使用Apache Felix OSGi Log Service实现进行测试。
在API /代码端,所有工作罚款:OSGi日志服务是标准的,所以我可以毫无问题地从Equinox交换到Felix。
然而,我观察到这种奇怪的行为:我启动了应用程序作为控制台程序,在控制台上查看日志输出,并附上JVisualVM以分析内存使用情况; JVisualVM图显示了一个80 MB的旧堆。
13个小时后,平均堆大小达到220 MB,所以我决定分析堆转储,我按下堆转储按钮:在此操作之后,JVisualVM图显示使用的堆为20(最小)-35(最大)MB(?!?!),并且该值是常量。
堆转储操作能否释放近200 mbs?如果是,为什么?
我从未在Equinox OSGi Log Service实现中看到这种行为,因此我怀疑Felix Log是否涉及此问题......
谢谢
是的,可以。我还没有研究过代码,但我很确定它会调用,第二个参数设置为true(如果从jconsole或MBeans中调用它,则为默认值扩展到JVisualVM)。根据我的经验,这样做会在转储堆之前触发一个显式的gc,这可能就是为什么?的答案。
i have a very strange problem.I'm working on an OSGi application, based on Eclipse Equinox; it was developed using OSGi Log Service (Equinox implementation) and now I'm testing it with the Apache Felix OSGi Log Service implementation.
At API/code side, all works fine: the OSGi log service is standard, so i can swap from Equinox to Felix without problem.
However, I observed this strange behaviour: I started the application as console program, to see the log output on console, and i attached it the JVisualVM to analize the memory usage; the JVisualVM graph showed an used heap of 80 MBs.
After 13 hours, the average heap size reached the 220 MBs , so i decided to analize the heap dump, and i pressed the "Heap Dump" button: after this operation, the JVisualVM graph showed an used heap of 20(min)-35(max)MBs (?!?!), and this value was constant.
Can "Heap Dump" operation release almost 200 mbs? If yes, WHY?
I never saw this behaviour with the Equinox OSGi Log Service implementation, so i suspect that the Felix Log is involved in this problem...
thanks
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?".
这篇关于可以JVisualVM“堆转储”吗?按钮释放内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!