Next: 3.6 Exceptions Up: 3. The libonyx library Previous: 3.4 Threads Contents Index

# 3.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 the thread doing garbage collection suspends all other threads that are created via thd_new(..., TRUE) during the mark phase. 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).