20 Garbage Collection

 

After reading lesson 20, you will be able to:

  • Understand how Java allocates memory for objects using the Heap
  • Understand how Garbage Collection (GC) works in Java

Even though memory has become less expensive and more compact, there are still physical limits to how much memory an application is allocated during runtime.  Early versions of Java required the programmer to manually search for unused objects and remove them to recapture this space. In this lesson, I will explain how this process is now automated and why it is important.

20.1   Java Heap

20.2   Garbage Collection

20.2.1   20.2.1  Nullifying the reference variable

20.2.2   Reassigning the reference variable

20.2.3   Creating an object inside a method

20.2.4   Island of Isolation

20.3   Summary