简体   繁体   English

是什么导致java minor gc

[英]what causes java minor gc

I am talking about UseParNewGC. 我说的是UseParNewGC。 My understanding of the java gc minor collection goes like this. 我对java gc minor集合的理解是这样的。 When, jvm detects that the eden is full (or it can't satify an allocation request) 何时,jvm检测到eden已满(或无法满足分配请求)

  1. It stops all app threads 它停止所有应用程序线程
  2. Computes the live objects in eden and one survivor space, and moves them to another 计算伊甸园和一个幸存者空间中的活动对象,并将它们移动到另一个
  3. If there is n't enough space for the move, or if the objects in survivor are old,enough, it does a promotion into old gen. 如果没有足够的空间来移动,或者幸存者中的物体已经足够陈旧,它将升级为旧一代。
  4. Marks eden and the cleaned survivor as empty 将伊甸园和清洗过的幸存者标记为空
  5. resumes app threads. 恢复应用程序线程。

Is the exactly right? 完全正确吗? Is there a case when minor gc will be triggered even though eden is not full? 是否存在即使eden未满也会触发次要gc的情况?

I think you got the process right. 我认为您的流程正确。 There are situations where a major GC is triggered for reasons other than a full eden space, such as a call to System.gc() , or RMI. 在某些情况下,主要的GC可能是由于充满eden空间以外的原因而触发的,例如对System.gc()或RMI的调用。 In that case a minor GC will also be run. 在这种情况下,还将运行次要GC。

When, jvm detects that the eden is full (or it can't satify an allocation request) In a way, yes. 何时,jvm检测到eden已满(或者它无法满足分配请求)。 But it dynamically sizes the generation to meet certain goals of the collector. 但是它会动态调整生成的大小,以满足收集器的某些目标。 Mainly pause time and fraction of CPU time spent in the GC. 主要是暂停时间和GC中花费的CPU时间的一部分。

So indirectly these goals dictate how often minor collections happen. 因此,这些目标间接地决定了次要收藏的发生频率。 Major collections may also trigger a minor collection before they run to reduce references to old objects from short-lived young ones. 主要集合还可能触发次要集合,以减少对短暂生命的年轻对象的引用。

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

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