Witscale Test Center

 6.4 How does the garbage collector work?


 6.4 How does the garbage collector work?

Whenever garbage collector runs, it recycles the memory allocated to the garbage object. In order to do so, it must be able to make a distinction between garbage (or unreachable) objects and reachable objects. The garbage collector uses one of the several algorithms or even a combination of multiple algorithms to do this distinction.  You cannot be sure of exactly which algorithms are used in the given JVM as that very much depends on the implementation of JVM.

 

For the exam you need not know details about the algorithms used to implement the garbage collection. However, you may find it helpful to have at least a higher-level view of these algorithms to get the overall picture.