Garbage collection

A crucial fact for clients of the garbage collector to know is that objects in the heap move. If all references to a traced heap object are from other traced heap objects, the collector may move the referent. Hence, it is a bad idea to hash pointer values. References from the stack or untraced heap into the traced heap are never modified.

The current collector is, by default, incremental and generational. The interruptions of service should be very small, and the overall performance should be better than with the previous collectors.

The use of VM protection has become obsolete by the addition of compiled-in hints for garbage collection since CM3 5.4. Now @M3novm is the default.

Note that the new optional background collection thread is not on by default; this may change in the future.

When you debug a Modula-3 program with m3gdb, you will find it simplest to run it with the @M3novm switch. More information on debugging in presence of the VM-synchronized garbage collector is available here.

m3gdb has its own reference documentation.

Because of the use of VM protection by the collector, there are some additional constraints on what programs may legally do. For example, you cannot pass an address on the heap as an argument to sigvec(2). These restrictions are documented in RTHeapDepC.c. If they seem onerous, we might be able to eliminate some. Note also that fork() and vfork() are now relatively expensive operations, since they cause the current collection to finish; this situation may improve in a future release.