O'Reilly logo

Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams by Jamie Jaworski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Does the Garbage Collector Work?

The Java garbage collector helps recycle memory and other resources when they are no longer needed. It consists of a separate low-priority thread of execution that executes in the background and keeps track of all the objects that are used in a Java program. When an object is no longer needed, it becomes subject to garbage collection.

At this point, you are probably wondering what it means for an object to be no longer needed and how the garbage collector determines which objects are needed and which are not. A program does not need an object that is no longer in use or that cannot be brought back into use. The garbage collector determines that an object cannot be used if it is no longer reachable by the program. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required