liam xu
liam xu

Reputation: 3030

When was Minor GC triggered?

I googled and found that most of the articles said that

'Minor GC is always triggered when JVM is unable to allocate space for a new Object,'

But from the visualVM, I found the minor gc happens very frequently. I can see the Eden space will be recliamed, then non-empty one of so,s1 will be cleared. So I think the minor gc is not triggered when the eden generation is full. enter image description here

Upvotes: 0

Views: 2303

Answers (2)

raghava
raghava

Reputation: 86

according to the graph you attached following are the reasons for minor GC:

1.In the graphs, metaspace is high for a long time so these leads to the full GC, which intern leads to minor GC.

2.And one more point is, don't look at the graph in the left because of having allocated, committed, used memory we can't say when the GC is occurring exactly, so look at the right side of the graph, if committed memory in the Eden space is equal to the used memory then minor GC occurs.

3.So finally minor GC occurring because of 1 and 2 reasons alternatively.

Upvotes: 2

AlBlue
AlBlue

Reputation: 24060

Allocation of new objects happens in an Eden region; when the Eden region is full, survivors are copied into the Survivor space and the remainder of the Eden space is thrown away. When the Survivor space is full the objects will be copied over to the other Survivor space (S0<->S1), and after a certain number of copies (3) the continued survivors will be copied to the heap. This happens all the time as you allocate objects. A major GC is when the full heap is swept for objects and is triggered when there is no more space to copy survivors to the main heap.

Upvotes: 0

Related Questions