The current implementation of CM uses a garbage collector (GC) known as Memory Pool System (MPS), which we license from the British company Ravenbrook.
MPS is an incremental, generational, mostly-copying garbage collector with support for ambiguous roots.
The "incremental" part means MPS will try to spread out the work that has to be done over time to avoid pausing the program noticeably. It has support for using multiple threads, but currently, we only use one thread for everything. The GC gets a chance to run every time new() is called, which happens in more places than are visible in the source code.
The "generational" and "mostly-copying" parts mean objects are moved around in memory during the course of execution. In consequence, object pointers are not constant but will be changed by the GC every now and then. Another consequence is that the iteration order of some data structures that use the pointer values for internal purposes becomes unpredictable. For instance, the traversal order of sets, such as Snapper{}, can be different from one time to another.
The "ambiguous roots" part means the GC can be used from C++ code, too. More precisely, it means it does not need to know exactly what on the system stack is a pointer to gc-allocated memory and what is just a bit pattern that happens to look like a pointer.
Generational garbage collectors are good at allocating many small and short-lived objects and don't cause memory fragmentation.
Comments
0 comments
Please sign in to leave a comment.