Keywords: onyx

Next: 4.6 Exceptions Up: 4. The libonyx library Previous: 4.4 Threads Contents Index

# 4.5 Garbage collection

Since there can be arbitrary threads executing in the interpreter concurrently, there are two ways to implement safe garbage collection: concurrent or atomic. libonyx uses atomic garbage collection, which means that during the mark phase, the thread doing garbage collection suspends all other threads that are created via thd_new(..., true). In order for this to work, the garbage collector must not do any locking while the other threads are suspended, or else there is a high probability of eventual deadlock. libonyx itself meets these criteria, as must any C extensions to the interpreter that are executed by the garbage collector during the mark phase (reference iteration).