Basic Garbage Collection

If you have some way to find all the objects in a system and some way to identify object references, garbage collection is simple.

  • You select a root set, the set of objects and scalar references that you know the program can reach. This contains static fields, local variables, parameters, and other data such as JVM internal pointers.

  • The root set and every object that can be reached on a path from the root set is live. All the other objects are dead and can be freed.

History of Garbage Collection

The LISP language is a well-known early application for garbage collection. It has no memory management facility other than the ability to create a cell, so like Java it needs garbage collection.

There is a strong connection between ...

Get Real-Time Java™ Platform Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.