Why Major Garbage collection is slower than Minor?

garbage-collection, java

Solution

1) Minor GC will first move 15 objects to one of survivor spaces, eg SS1, next GC will move those who are still alive to SS2, next GC will move those who survived back to SS1 and so forth. Only those who survived several (eg 8) relocations (minor GCs) will finally go to old generation.

2) Major GC happens only when JVM cannot allocate an object in old generation because there is no free space in it. To clean memory from dead objects GC goes over all objects in old generation, since old generation is several times larger than new generation, it may hold several times more objects, so GC processing will take several times longer

Problem

Gone thru this link but still has confusion what actually happens in minor and major GC collection. Say i have 100 objects in younger generation out of which 85 object are unreachabe objects. Now when Minor GC runs, it will reclaim the memory of 85 objects and move 15 objects to older(tenured) generation. Now 15 live objects exists in older generation out of which 3 are unreachable. Say Major GC takes places. It will keep 15 objects as it is and reclaim the memory for 3 unreachable object. Major GC is said to be slower than minor GC. `My question is why ? Is it because of major GC happens on generally greater number of objects than minor as minor gc occurs more frequently than major?` As per understanding `major GC should be faster as it needs to do less work` i.e reclaiming memory from unreachable objects than minor GC because high mortality rate in young generation.

Original source