Videos: Garbage Collection
slides: gc.pdf |
Note that the implementation videos, which are included in the playlist, are optional.
Automatic memory management relives the programmer of the tedious and error-prone task of determining where to put calls to free. We look at the two main forms of automatic memory management: reference counting and garbage collection.
The example implementations described in these videos are available as gc-demo.zip or https://github.com/mflatt/gc-demo.
- Motivation and overview for automatic memory management.
- Reference counting is a form of automatic memory management that centralizes the tracking of how many references to an object are outstanding, so the object’s memory can be freed when the last reference is removed.Reference counting has sometimes been called a form of garbage collection. It makes more sense to say that reference counting and garbage collection are two forms of automatic memory management.
- An overview of a referencing counting algorithm.
- A walk-through for an implementation of reference counting. This video also explains the organization of the example code that shows reference counting and garbage collector variations.This video is optional, because you will not need to know the implementation details for any homework assignment or test. Still, a look at the implementation is recommended, because it covers all sorts of details to help you see how reference counting really works.
- Reference counting doesn’t handle cycles.
- Garbage collection handles cycles by addressing the more direct question of “which objects can still be used by the program?” instead of “which objects are referenced from somewhere?”
- An overview of a garbage-collection algorithm.
- A walk-through for an implementation of garbage collection.This video is optional for the same reason that all of the implementation videos are optional (see above).
- Conservative garbage collection implements automatic memory management without specific support from the language implementation.The Boehm collector is the seminal and widely used conservative collector for C.
- A walk-through for an implementation of conservative garbage collection.This video is optional for the same reason that all of the implementation videos are optional (see above).
- A two-space copying collector implements an especially simple allocation and collection strategy that usually performs well.
- A walk-through for an implementation of a two-space copying collector.This video is optional for the same reason that all of the implementation videos are optional (see above).
- A more realistic garbage collector deals with multiple shapes of values, instead of just tree nodes. Tags are typically associated with objects to identify shapes tp the garbage collector.
- Stepping through the operation of a two-spece collector on tagged objects in a tiny setting.
- Some pointers and comments on GC topics that are not covered here.