About compaction: it depends on the algorithm used. Since all GCs of the new generation are copied by collectors: yes, they make a camp, they even move all the preserved objects to another memory area. With older generation collectors, it depends on which data collection algorithm is used. While the standard compact mark-seal collector is compacted (well, thatβs why it is βcompactβ), the CMS collector (parallel marking) usually does not make any compact if it is not inevitable and therefore needs to manage heap fragmentation.
And when objects are moved (due to use of the copy picker or due to compaction), existing links are updated to indicate a new memory location.
source share