-
Notifications
You must be signed in to change notification settings - Fork 72
Garbage collector
SpurMemoryManager
is an object representation and garbage collector for the Cog VM's
When the garbage collector(GC) run, objects that nobody points to will be deleted. Most of the time, the garbage collector will only run on the new space (see here for memory structure), because this is where it is most likely to find objects to remove. To avoid going through all objects in the old space for pointers to the new space, a list is kept in the Remembered Set. The Remembered Set is implemented by VMRememberedSet
. It is heap allocated. Then the garbage collector can go only through the new space and use the Remembered Set to know if an object is referenced from the old space.
When the GC run, all surviving new space objects are moved in the Future. Then the Future memory area becomes the past for the next cycle/generation and the old Past is used as the new Future.
Once the Generation Garbage collector is done :
- Eden is empty
- Future is empty
- Past (old Future) object contains the surviving objects When an object survives many runs of the GC, it can be promoted to the old space.
The GC is unaware of old space segments. It can go to the next object without knowing the implementation specific thanks to bridges. As the bridge is opaque, the GC will not look inside for references and will simply move to the next object using the apparent size of the bridge.