|
|
|
|
|
by dumael
5282 days ago
|
|
Concurrent GC is somewhat non-trival as the mutator (i.e. the program you write) can delete references to objects from an area of the heap that has not been examined by the GC and introduce references to those same objects in an area that has been examined. This means those objects will be reclaimed since the GC never saw them. To cope with this the mutator is modified at compile/run time to inform the GC of object updates that could lead to this situation. During compaction of any sort, the first time an object is encountered that is to be moved it is copied somewhere else and the old copy's header is overwritten with it's forwarding address. Every time the GC encounters a reference to the old object, it re-writes the reference to the old object with it's new location (conveniently located in the old copy's header). > Is it possible that a reference value is a pointer to a reference "object" which contains the pointer to data, which needs to be updated? Look up something called 'Brook's style forwarding pointer', it is essentially what you've described. |
|
Your explanation for compaction makes perfect sense. Of course, this won't work trivially concurrently. Only if you stop the world can you complete examination of the entire live heap and know you've updated all references to the moved object and can collect the original space.