Aug 21, 2001
Using System.gc() to Force the Garbage Collector
The garbage collector works automatically, whether you request it to or not. However, it is possible to make a garbage collector request, by invoking the System.gc() method. When garbage collector starts its work, you may have a short pause in the application's execution. This is the reason why you should only invoke the System.gc() method at the right time, such as before performing a huge task or when the application is idle, waiting for user's input.