Unformatted text preview: servative collector for C programs into an existing malloc package, as shown in Figure 10.52.
dynamic storage allocator C application program malloc() conservative garbage collector free() Figure 10.52: Integrating a conservative garbage collector and a C malloc package. The application calls malloc in the usual manner whenever it needs heap space. If malloc is unable to ﬁnd a free block that ﬁts, then it calls the garbage collector in hopes of reclaiming some garbage to the free list. The collector identiﬁes the garbage blocks and returns them to the heap by calling the free function. The key idea is that the collector calls free instead of the application. When the call to the collector returns, malloc tries again to ﬁnd a free block that ﬁts. If that fails, then it can ask the operating system for additional memory. Eventually malloc returns a pointer to the requested block (if successful) or the NULL pointer (if unsuccessful). 10.10.2 Mark&Sweep Garbage Collectors
A Mark&Sweep garbage coll...
View Full Document