视觉VM强制GC
我对 POJO 的内存使用情况进行采样并计算实例数量。如果当我在视觉虚拟机中按“垃圾收集”并且我可以看到实例关闭时,这是否意味着它没有内存泄漏?
如何强制jvm每天午夜进行垃圾收集? (就像在 VisualVM 上自动按垃圾收集一样)?我看到 VisualVM 的 cpu 使用率,gc 始终为 0%。我设置了-xmx -xms 1024m,但通常内存使用量在200mb左右。这是因为 GC 仅在必要时才进行吗?这就是为什么 gc cpu 时间总是 0%
如何检查上次执行“full GC”的时间?
i sampling the memory usage and count number of instances for POJO. if when i press 'garbage collecting' in visual vm and i can see the instances down , does that mean it's memory leak free ?
how to force jvm do garbage collecting everyday at midgnight ? (just like automatically press garbage collect on visualvm) ? i see visualvm 's cpu usage, gc is always 0%. i set -xmx -xms 1024m, but normally memory usage around 200mb. is this because GC is only done when necessary? that's why always 0% for gc cpu time
how to check the time of last time doing 'full GC' ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
System.gc()
,这是一个提示给 JVM 它现在可能想要运行 GC。它不需要做任何事情,并且该方法的无操作实现将是完全有效的。基本上,垃圾收集“自然而然地发生”,并且您对它的特定期望越少越好。所以基本上,是的,它通常只会在需要时运行。-verbose:gc
将详细的垃圾收集详细信息输出到控制台。如果您想以编程方式或视觉方式检查详细信息,此信息也可能通过 JMX 公开(即 设置您的流程以使用 JMX 远程处理,并使用 JConsole 连接到它)。对于我来说,使用 Sun 的 1.5.0_06 JVM,我在 java.lang.GarbageCollector 中看到一个 MBean,它公开了一些信息,包括上次完整 GC 的时间。System.gc()
, which is a hint to the JVM that it might want to run GC now. It doesn't have to do anything, and a no-op implementation of that method would be perfectly valid. Basically, garbage collection "just happens" and the less you place specific expectations on it the better. So basically, yes, it will typically only run when needed.-verbose:gc
to get verbose garbage collection details output to the console. If you want to inspect the details programmatically or visually, this information might be exposed via JMX too (i.e. set up your process to use JMX remoting, and connect to it with JConsole). For me, using Sun's 1.5.0_06 JVM, I see an MBean in java.lang.GarbageCollector that exposes some information including the time of the last full GC.没有。没有真正具体的方法来确定您的应用程序是否没有内存泄漏。最好的方法是长时间运行浸泡测试,并确保活动堆的大小稳定。
您可以使用
System.gc()
方法调用来运行垃圾收集器。似乎没有 API 可以获取上次 GC 运行的时间,但是 GarbageCollectorMXBean 可以提供一些有关 GC 的统计信息。
No. There is no really concrete way to determine if your application is memory leak free. The best is to run a soak test over an extended period of time and ensure that the size of the live heap is stable.
You can use the
System.gc()
method call to run the garbage collector.There doesn't seem to be an API for getting the last time a GC has run, however the GarbageCollectorMXBean can give some statistics about the GC.