Chi Shin Hsu
Chi Shin Hsu

Reputation: 273

Minor GC but Eden space is not full

Minor GC is used to clean Eden space, right? but I used jstat to watch my GC logs. There are 95% minor GC is occur when Eden space is 90% full. However sometimes it happens by I find the Eden space is almost empty.

I use jdk7 and g1gc. My program handles fifty thousand requests per second. Every shortly pause cause by GC would be obviously.

For what other reasons would the GC decide to perform a minor collection?

Upvotes: 1

Views: 550

Answers (1)

K Erlandsson
K Erlandsson

Reputation: 13696

Jstat shows you sampled data. For example, if you run jstat -gc <pid> 2s, jstat shows you snapshots of the heap and gc states every two seconds.

Hence, eden could very well have been at 100% when the collection happened but the snapshot you saw in jstat was taken some time after a collection happened.

There are other explanations too, for example the G1 collector collects eden before it is 100% full. Allocation of a huge object could also trigger a gc when eden seems to be less than full.

Upvotes: 1

Related Questions