- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make an object eligible for garbage collection in Java?
Java Garbage collector tracks the live object and objects which are no more need are marked for garbage collection. It relieves developers to think of memory allocation/deallocation issues.
JVM uses the heap, for dynamic allocation. In most of the cases, the operating systems allocate the heap in advance which is then to be managed by the JVM while the program is running. It helps in following ways:
Faster object creation as Operating system level synchronization is no more needed for each object. Object Allocation takes some memory and increases the offset.
When an object is not required, garbage collector reuses the object's memory for further allocation.
As objects forms tree, they have one or more root objects. If root objects are reachable, the whole tree is reachable. There are some special objects as well which are garbage collection roots (GC roots) and are always reachable.

- Related Articles
- When will be an object eligible for garbage collection?
- How many ways to make an object eligible for GC in Java?
- How to prevent object of a class from garbage collection in Java?
- Garbage collection in Java
- Java Garbage collection
- How to force garbage collection in C#?
- How can we call garbage collection (GC) explicitly in Java?
- Using the finalize() method in Java Garbage Collection
- How to make an object completely encapsulated in java?
- Garbage Collection in Python
- How does garbage collection work in Python?
- How to make a collection read only in java?
- How to make a collection thread safe in java?
- When are python objects candidates for garbage collection?
- Garbage collection(GC) in JavaScript?
