简体   繁体   中英

what causes java minor gc

I am talking about UseParNewGC. My understanding of the java gc minor collection goes like this. When, jvm detects that the eden is full (or it can't satify an allocation request)

  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?

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. In that case a minor GC will also be run.

When, jvm detects that the eden is full (or it can't satify an allocation request) In a way, yes. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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