简体   繁体   English

什么条件会阻止JVM运行FULL Garbage Collection?

[英]What conditions would prevent the JVM from running a FULL Garbage Collection?

What conditions would prevent the JVM from running a FULL Garbage Collection when the CPU is at 5% to 8% load? 当CPU处于5%到8%的负载时,有什么条件会阻止JVM运行FULL Garbage Collection?

I am seeing a constant shallow GC cycle, but not able to tune the JVM to want to run FULL GC. 我看到一个持续浅的GC循环,但无法调整JVM以运行FULL GC。

Where can I go to find the conditions that the JVM says "I am too busy to run". 我在哪里可以找到JVM说“我忙得跑”的条件。

When I was studying for my SCJP certification a lot of emphasis was made on 当我在学习SCJP认证时,我们非常重视

"You can not do anything to force the GC to run at any given time, you can just give hints to it" “你无法做任何事情来强制GC在任何给定时间运行,你可以给它提示”

The whole idea of having an automatic GC is precisely not having to worry about how or when it runs to clean up free memory for you. 拥有自动GC的整个想法正是不必担心它如何或何时运行来为您清理可用内存。 So, there is no way to actually change when or how GC does actually run... you would have to re-implement one JVM to do what you want. 因此,无法实际更改GC实际运行的时间或方式......您必须重新实现一个JVM才能执行您想要的操作。

There are just so many factors involved in this, there may be other, more elegant solutions for this. 这里涉及的因素很多,可能还有其他更优雅的解决方案。

It depends entirely on the garbage collector algorithm that you're using in your particular JDK. 它完全取决于您在特定JDK中使用的垃圾收集器算法。 About all you can guarantee about garbage collection is that if the JVM throws an OutOfMemoryError , the garbage collector made its best effort to collect every unreachable/weakly reachable object. 关于垃圾收集的所有可保证的是,如果JVM抛出OutOfMemoryError ,垃圾收集器会尽最大努力收集每个无法访问/弱可访问的对象。 Even System.gc() doesn't guarantee anything, a no-op is a completely legal implementation. 即使System.gc()也不保证任何内容,no-op是完全合法的实现。

Hence in that light I don't know if your question has any weight. 因此,从那个角度来看,我不知道你的问题是否有任何重要性。 If you truly believe that you need to tweak the garbage collector, it would help if you posted the problems you're seeing, and the profiling data that leads to believe that poor GC performance is the problem. 如果你真的相信你需要调整垃圾收集器,那么如果你发布了你所看到的问题,那将会有所帮助,并且分析数据会导致认为GC性能不佳是问题所在。

Outside of this, the garbage collector should be treated like a black box. 除此之外,垃圾收集器应该被视为黑盒子。 The logic behind its implementation is surprisingly complex, and there's a very good chance it knows better than you what it ought to be doing at any given time. 它实现背后的逻辑非常复杂,而且它很有可能比你更了解它在任何特定时间应该做的事情。 99 times out of 100, trying to force the garbage collector to behave in a particular way will lower performance, not increase it. 100次中的99次,试图强制垃圾收集器以特定方式运行会降低性能,而不是增加它。

这不是忙于运行,但它确实不需要额外的内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM