WestFarmer
WestFarmer

Reputation: 775

what will happen when eden is full but all objects in it is alive

I am learnging Java memory management, From what I already learned from internet.

Minor GC is triggered when Eden space is full, Minor GC will copy objects still being referenced to one survivor space which is empty, but that space is smaller than Eden, What will collector do when eden is full of alive objects ? AFAIK,Java GC Collector is copying collector, it should move all live objects away then clear old memory space.

Upvotes: 0

Views: 384

Answers (1)

Eugene
Eugene

Reputation: 121088

Minor GC is triggered when Eden space is full

almost correct. A minor GC can be triggered when a major GC is triggered. It's like the GC says : "I need to do a Full GC, but first I'll do a minor one". In that case (G1 does this, for example), Eden space might not be full.

When that happens (some Eden regions could not be completely evacuated), those regions are made old, as even commented here:

Regions that failed evacuation are always made old...

Upvotes: 1

Related Questions