Originally Posted by
jwenting
You can't force the GC, at best you can hint it (and doing so is usually counterproductive in that it forces the GC to (if it runs on the hint at all) perform a full GC cycle rather than an incremental GC cycle, consuming unnecessary CPU cycles, and can be forcibly ignored through JVM configuration).
Just about the only time you may want to do that is when you have an application that you know will require a lot of memory for a longrunning operation. Just before consuming that memory you might want to try and get the GC to run so you have as much free RAM as possible, hopefully reducing GC overhead during that expensive operation.