I am surprised with this behaviour especially because the API
doc says the following:
The call System.gc() is effectively equivalent to the call:
Runtime.getRuntime().gc()
From the above statement one would assume that both the calls would behave in a similar way.
Any body any ideas....
Roopa
Originally posted by ashok khetan:
hi! in the following code, when we execute it, the finalize() method is called as the result of line 1 and 2. So should we assume that the behaviour of Runtime.getRuntime().gc() is certain?? One more thing if we use System.gc() instead of Runtime..then it doesn't call finalize().
thanx.
ashok.
________________
class best {
public void finalize() {
System.out.println("In finalize");
}
public static void main(String argv[]){
best e = new best();
e = null;
Runtime.getRuntime().gc(); //1
best e1 = new best();
e1 = null;
Runtime.getRuntime().gc(); //2
}
}
________________