Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 15. Garbage Collection > Garbage Collection: The Theory

Garbage Collection: The Theory

The task of a garbage collector is to find objects that are no longer being used by a running program and deallocate them—return the their bytes to the heap so that the bytes can be reused.

Garbage collection is simple in principle. Any object that is known to be in use or can be reached by following a chain of references (pointers) from an object known to be in use is considered to be “live.” All other objects are considered to be “garbage” and are collected. The memory used by the garbage objects is returned to the heap.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial