有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java总是被gc调用,即使堆空间在运行时持续可用?

根据Java平台《标准版热点虚拟机垃圾收集调优指南》中标题为"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甚至不会发生一次

如果会发生,原因是什么?因为这似乎与链接文档相反


共 (1) 个答案

  1. # 1 楼答案

    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运行时来管理内存,这包括决定何时(或是否)进行垃圾收集