Garbage Collection depth Understanding : | ||||||||||||||
i. If a method hold reference variable, where method have a reference Object return type
ii. If a method not hold any reference variable, where method have a reference object return type.
iii. If a method hold a global object reference variable, where method have a reference object return type.
protected void finalize() throws Throwable{} in Object class
· so this method is empty implementation
When run finalized method by programmer. If runtime get any exception then the program terminate abnormally. Then we get UnCaughtException by raising that exception
When run finalized method by JVM. If runtime get any exception then the program terminate normally.
Class Test{
public static void main(){
Test t=new Test();
t.finalize();
}
public void finalize(){
System.out.println(“Mandal”);
}
}
The object which are not use in our program and no to call garbage collector that type of object occur memory leak. So different type of tools like HP-J-Meter, IBM –
|
Example 1 Java Garbage Collection: |