Garbage collection is a very CPU-intensive activity; while it is occurring, no application logic can be executed. While the Java API provides a method of invoking the garbage collector from application code, it is best practice to let only the JVM decide when to perform garbage collection. If an application contains explicit calls to
System.gc(), then these can significantly impact performance. Luckily, Java includes a flag that allows us to disable calling the garbage collector programmatically.
This recipe assumes you are using the HotSpot JVM, if you are using JRockit, see the There's more… section of this recipe for the parameter you need.
For more details, refer to the Getting ready section of Setting the ...