Nasal GC Musings: Difference between revisions

Jump to navigation Jump to search
Line 32: Line 32:
The garbage collection process is initiated by the garbageCollect function, which is called when the garbage collector is needed. This function first searches through all contexts in the program to mark all reachable objects, then it marks several global objects, and finally it calls the reap function for each object type to free any unreferenced objects.
The garbage collection process is initiated by the garbageCollect function, which is called when the garbage collector is needed. This function first searches through all contexts in the program to mark all reachable objects, then it marks several global objects, and finally it calls the reap function for each object type to free any unreferenced objects.


The garbage collector is called from several places in the code, including the naModUnlock function, which is called when a thread releases its lock on the global data structures. This allows the garbage collector to run concurrently with other threads, which can help improve performance. However, there are also situations where the garbage collector needs to run exclusively, such as when it needs to free the list of dead blocks. In these cases, the bottleneck function is called to engage the "bottleneck" and block all other threads until the garbage collector has finished running.
The garbage collector is called from several places in the code, including the naModUnlock function, which is called when a thread releases its lock on the global data structures. The garbage collector needs to run exclusively, such as when it needs to free the list of dead blocks. In these cases, the bottleneck function is called to engage the "bottleneck" and block all other threads until the garbage collector has finished running.


== mark/sweep GC ==
== mark/sweep GC ==

Navigation menu