Skip to main content

GC Fundamentals

Learn GC Fundamentals (Garbage Collection, Java) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

6. Basic Concepts What is Garbage Collection? Garbage Collection (GC) is the process by which the Java Virtual Machine (JVM) automatically finds objects that are no longer being used by your program and reclaims the memory they occupy. In languages like C or C++, the programmer must manually call free() (or delete ) to release memory. Forget to do it, and you get a memory leak . Do it too early or twice, and you get a crash. Java removes this burden - a background process called the Garbage Collector does this cleanup for you.

More lessons in Garbage Collection