posted 22 years ago
Hi,
I think one can forcefully run the garbage collector by calling System.gc() method.In this way you force garbage collector to be called to reclaim the memory.If a forceful call is not done then the gc is called only when the JVM finds it is running low in memory,otherwise it will not call garbage collector and the memory will be reclaimed by the Operating System when the program ends.Although calling garbage collector is a waste of time.So I think b and e both are right and since I have no idea of any information being given to object by the gc, I'll stay quite.
If you want to see an example where you call gc and see the process of gc,then here is the code:-
One thing that I must add to the behavior of the program is that Iam not assigning it to any variable of A (see line#1) ,thus the objects created using new remains unreferenced thereby creating work for garbage collector.Had it been assigned to any object reference gc would'nt have work.I found it out lately.
This is what my understanding says,I may be wrong, so please correct me.
THANKS
[This message has been edited by Bindesh Vijayan (edited August 29, 2001).]