简体   繁体   English

Java 的幸存者空间满时

[英]Java’s survivor space when full

What happens when Java's survivor space is full but the Eden's space has free memory?当 Java 的幸存者空间已满但 Eden 的空间有空闲内存时会发生什么? Does the survivor space uses the Eden's space?幸存者空间是否使用伊甸园的空间?

What happens when Java's Survivor space is full but the Eden's space has free memory?当 Java 的 Survivor 空间已满但 Eden 的空间有空闲内存时会发生什么?

It will depend on the GC.这将取决于 GC。 And it also, on whether the Survivor space is at the max (as distinct from just being full).而且,它还关于 Survivor 空间是否处于最大值(不同于刚刚满)。 But shrinking Eden space to allow the Survivor space to grow is one possible strategy.但缩小 Eden 空间以允许 Survivor 空间增长是一种可能的策略。

Note: shrinking Eden space won't be good for performance.注意:缩小 Eden 空间对性能不利。 It is liable t0 increase the rate of minor GCs, and ultimately major GCs.有责任增加次要 GC 的发生率,并最终增加主要 GC 的发生率。


I took a brief look at the source code for the G1 collector in JDK 17. It appears 1 that G1GC has no provision for shrinking Eden space.我简单地看了一下 JDK 17 中 G1 收集器的源代码。似乎1 G1GC 没有提供缩小 Eden 空间。 (Look at the file "/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp") (查看文件“/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp”)


1 - Caveat: the context of the code I looked at is complicated, and I could easily have misunderstood it. 1 - 警告:我查看的代码上下文很复杂,我很容易误解它。 YMMV. YMMV。

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

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