No, there should never be a need to call those methods. If you've written your code correctly and provided the right parameters at JVM startup, those will have little or no effect.
In certain special cases, things might run more smoothly (fewer noticeable bumps) at the cost of slightly lower overall throughput if you explicitly invoke GC, and in certain rare cases, explicitly invoking GC might prevent an OutOfMemoryError, but I would only add it as a last resort, after first examining my design and code and reviewing my startup JVM params.
in certain rare cases, explicitly invoking GC might prevent an OutOfMemoryError
Really? I thought the JVM guarantees that no OutOfMemoryError is thrown if memory can be freed up by garbage collection?
In any case, I agree that if you have OutOfMemoryErrors, calling Runtime.gc() is never a solution. You need to look at ways to use less memory (allow objects to be garbage collected) first, then consider other options like writing rarely accessed data to disk, distributing the work over more machines or scaling up your machines (add memory).
SCJP 1.4 -- SCJD Java 2 -- OCM JEA 5
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com