Category: React • Beginner
Published on 22 Feb 2026
Explanation
#white-Garbage Collection is the automatic memory #white-management process that removes unused objects.
Code Example
String str = new String("Hello");
str = null; // Eligible for GC
Explanation
#white-System.gc() is used to request JVM to #white-perform garbage collection.
Code Example
System.gc();
Explanation
#white-An object becomes eligible for garbage #white-collection when it has no references.
Code Example
Object obj = new Object(); obj = null;
Explanation
#white-finalize() method was used to perform #white-cleanup before GC #white-(deprecated in modern Java).
Code Example
@Override
protected void finalize() throws Throwable {
System.out.println("Object collected");
}
Explanation
#white-JVM manages heap memory and garbage #white-collection automatically.