St.Antario
St.Antario

Reputation: 27435

Survivor space changing, why that?

As noted in the oracle java GC basic documentation when any minor GC is triggered all object located in S0 sirvivor space (if any) are moved into S1 sirvivor space or vice verca. It seems strange to me, to say the least. To perform the operation the GC waste a JVM resources to moving objects from Si to Sj, i!=j, i,j are from {1, 2}. May I not follow the actual purpose of that operation... Couldn't anyone explain it to me?

Upvotes: 0

Views: 146

Answers (1)

niceman
niceman

Reputation: 2673

This is how GC seperate variables' scope, so a variable in a class would be in S0 but when getting into a method GC is triggerd so that local variables in the method becomes S0 and the variables in the class becomes S1.
When getting out of the method, GC is triggerd again, the local variables are destroyed and the variables in the class are moved to S0 and when out of the class they are destroyed(note that variables in the class mean any variables we can reach not just static variables).

Upvotes: 1

Related Questions