Java – what is the fundamental difference between evacuation and compression in garbage collection?
I've read a lot of documentation about hotspot GC for Java se 6 and 7 When it comes to the strategy of obtaining the continuous area of free memory, two "competitive" methods are proposed: evacuation method (usually applied to young people)), active object from 'copy to empty' to 'and compression (retreat of CMS), in which the active object moves to one side of the fragment area to form a continuous unused block memory
Both methods are proportional to the size of the "real time set" The difference is that evacuation requires x2 times of space, while the actual set does not need to be compressed
Why do we need evacuation technology? The amount of replication that needs to be done is the same, but it needs to preserve more heap size and does not allow faster remapping of references
Yes: evacuation can be performed in parallel (where - compression cannot, or at least not so easy), but this feature has never been mentioned and seems less important (considering that remapping is much more expensive than moving)
Solution
A big problem is that during "evacuation", the space vacated is indeed empty, while during "compaction", some other objects y may be moved to the space where object x is located This makes it more difficult to correct the pointer, because people can't simply use the fact that the pointer points to an invalid position to prompt the code that needs to be updated And the forward pointer cannot be stored in an invalid location
This makes GC less concurrent - the application must be "GC frozen" for a long time