Marking live data and sweeping the rest
This section gives an overview of the Unicon garbage collector, which is a mark-and-sweep style of garbage collector that was developed for the Icon language and then extended. It is written in (an extended dialect of) C, like the rest of the Icon and Unicon runtime system. Since Unicon inherited this garbage collector from Icon, much of what you see here is due to the many folks who implemented that language. All I did to it was add its “multiple regions” support, which seemed like a good idea at the time of 64KB heap limits on 640KB MS-DOS computers. Other aspects of this garbage collector are described in the book The Implementation of Icon and Unicon: a Compendium.
In almost all garbage collectors other than reference counting, the approach to collection is to find all the live pointers that are reachable from all the variables in the program; everything else in the heap is garbage. In a mark-and-sweep collector, live data...