在 Java 堆上,我预期年轻代的大小将是伊甸园空间和两个幸存者空间(从空间和到空间)的总和:
[young gen size] = [eden space size] + [from space size] + [to space size]
但是,GC 日志(使用 XX:+PrintHeapAtGC
)指出,年轻代的大小是eden 空间和仅一个幸存者空间大小的总和:
[young gen size] = [eden space size] + [from space size]
为什么年轻代的大小只包含一个survivor空间的大小?
也许是因为任何时候都只有一个幸存者空间可用?但是两个幸存者空间都存在,所以两个幸存者空间都应该对新一代的规模做出贡献?
GC日志:
{Heap before GC invocations=48 (full 17):
par new generation total 943744K, used 891496K [0x000000073ae00000, 0x000000077ae00000, 0x000000077ae00000)
eden space 838912K, 100% used [0x000000073ae00000, 0x000000076e140000, 0x000000076e140000)
from space 104832K, 50% used [0x000000076e140000, 0x000000077149a040, 0x00000007747a0000)
to space 104832K, 0% used [0x00000007747a0000, 0x00000007747a0000, 0x000000077ae00000)
来自:
[young gen size] = [eden space size] + [from space size]
943744K = 838912K + 104832K
最佳答案
任何时候,幸存者空间之一始终是空的,因此不能将其视为可用。
关于java - 缺少内存 : size of young generation includes only one survivor space,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55940990/