Garbage Collector is
the program running in the background that looks into all the objects in the
memory and find out objects that are not referenced by any part of the program.
All these unreferenced objects are deleted and space is reclaimed for
allocation to other objects.
One of the basic ways of garbage collection involves
three steps:
1.
Marking:
This is the first step where garbage collector identifies which objects are in
use and which ones are not in use.
2.
Normal
Deletion: Garbage Collector removes the unused
objects and reclaim the free space to be allocated to other objects.
3.
Deletion
with Compacting: For better performance, after
deleting unused objects, all the survived objects can be moved to be together.
This will increase the performance of allocation of memory to newer objects.
There are five types of garbage collection types
that we can use in our applications. We just need to use JVM switch to enable
the garbage collection strategy for the application. Let’s look at each of them
one by one.
No comments:
Post a Comment