Automatic Garbage Collection
Automatic garbage collection is the process of identifying the used and unused objects in heap memory and deleting the unused objects to reclaim memory.
- Used Object / Referenced Object : The object which is referenced by some part of the program.
- Unused object / Unreferenced object : The object which is no longer referenced by any part of the program. So it can be deleted to reclaim memory.
In a programming language like C, allocating and deallocating memory is a manual process. In Java, process of deallocating memory is handled automatically by the garbage collector.
A general Garbage Collection implementation involves three steps:
- Marking : To identify and mark used & unused memory
- Sweeping/Deleting
- Compaction
REFERENCES
- https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
- https://stackify.com/what-is-java-garbage-collection
- https://www.freecodecamp.org/news/garbage-collection-in-java-what-is-gc-and-how-it-works-in-the-jvm/
0 Comments