Example & Tutorial understanding programming in easy ways.

What is garbage collection?

Garbage collection is an important part of Java security strategy. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables objects from the memory.

The name garbage collection implies that objects that are no longer needed by the program are garbage and this object will destroy by garbage collector . A more accurate and up-to-date metaphor might be memory recycling. When an object is no longer referenced by the program, the heap space it occupies must be recycled so that the space is available for subsequent new objects.

The garbage collector must somehow determine which objects are no longer referenced by the program and make available the heap space occupied by such unreferenced objects.

In the process of freeing unreferenced objects, the garbage collector must run any finalizers of objects.

Read More →