Saturday, January 21, 2017

Garbage Collection and Tuning

Garbage Collection : Destruction of unnecessary objects mechanism is called Garbage collection.Garbage collector is responsible for this mechanism.

Objects are eligible for GC: 

1) Whenever object does not have any reference variable.
2) Programmer can make object is eligible for GC if it is no longer required.

Methods to make object eligible for GC:

1) Nullifying Reference Variable
2) Reassigning reference variable  to another object - so old object eligible for garbage collection
3) Objects created inside a method
4) Island of Isolation

Methods JVM to Run GC:

1) System class method - system.gc();
2) By using Runtime class




No comments:

Post a Comment