根据 Java 平台标准版 HotSpot 虚拟机垃圾收集调优指南 标题为 "Generations" 的部分
When the young generation fills up, it causes a minor collection in which only the young generation is collected
和:
Eventually, the tenured generation will fill up and must be collected, resulting in a major collection, in which the entire heap is collected.
所以如果应用程序已经完成了分配阶段,并且 在整个应用程序的执行过程中,年轻代和老年代都没有被填充(在任何阶段都没有),那么gc甚至不会发生一次?
如果会发生,原因是什么?因为这似乎与链接的文档相反。
最佳答案
So if the application finished the allocation phase, and throughout the execution of the application, the young and tenured generations are not filled up (at all, in any stage), the gc will not occur even once ?
是的。如果年轻代和老年代没有被填充(在任何阶段),那么 gc
可能 不会发生(甚至一次)。由 JVM 运行时来管理内存,这包括决定何时(或是否)发生垃圾收集。
关于java - 是否始终调用 gc,即使堆空间在运行时连续可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34551348/