SLIDE 28 Principles of programming languages Maarit Harsu / Matti Rintala / Henri Hansen
TUT Pervasive Computing
28
Garbage collection methods
– keep track of the number of pointers that refer to the same memory location
– before collection all memory allocations are marked as not seen – referenced allocation blocks are marked as seen – sweep phase sweeps away all allocations that are not seen
– memory space is split into two parts, and only one of them is used for new object allocations – in garbage collection, reachable objects are copied from the allocation space (from-space) to the other, initially empty space (to-space) – finally the roles of these two spaces are switched