JVM Garbage Collection : Garbage Collection « Java Source And Data Type « SCJP






Automatic garbage collection is done in the background by a low-priority thread. 
The garbage collector calls the class destructor-method finalize() if defined and then frees the memory.
The methods System.gc() and Runtime.gc() suggest that the Java Virtual Machine to recycle unused objects.
Only the JVM decides when to run the GC, you can only suggest it.
Java applications can run out of memory.
The finalize() method is guaranteed to run once and only once before the garbage collector deletes an object.
The garbage collector makes no guarantees, finalize() may never run.
You can uneligibilize an object for GC from within finalize().








1.27.Garbage Collection
1.27.1.JVM Garbage Collection
1.27.2.How to Cause Leaks in a Garbage Collection System
1.27.3.Avoiding the memory leak
1.27.4.To remove a reference to an object is to set the reference variable to null.
1.27.5.Reassigning a Reference Variable to remove a reference to an object
1.27.6.If an object is returned from the method, its reference might be assigned to a reference variable;
1.27.7.Free memory result should indicate whether Garbage collector has run
1.27.8.An Example of Garbage Collection in Action