Originally posted by chowdaryv: when is garbage collector actually into action.if i use system.gc() then when it will get invoked.
All the call to System.gc() does is suggest to the thread schedular of your operating system that the Garbage Collector should run. When and if it runs is up to it so, you can't be positive when it will run.
There is no way to tell when the garbage collector will actually execute, in fact it might never execute at all.When you invoke the method system.gc(), all you are doing is suggesting,humbly so, that you would very much appreciate if the garbage collector was run.Whether and when it actually gets to run is not anything you can control.Usually the gc will run as response to a runtime request from the VM, which often times is a consequence of your program exhausting all its memory on the heap, so much so that some resources need to be released and memory be made available to your program.The exact implementation of garbage collection is platform dependent and its behaviour in general is not guaranteed. Herbert