Changing an object reference after GC

I have little confusion regarding the GC when the GC executes it, stops all threads and collects garbage links.

after GC, does jvm perform any compaction?

Sealing: means moving "used" memory areas to eliminate holes caused by completed links

if so, does jvm support old links or assign a new link to all other objects?

+5
source share
1 answer

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.

+7
source

Source: https://habr.com/ru/post/1243557/


All Articles