Usage:
The flag “-XX:+DisableExplicitGC” disables processing of calls to the System.gc() method.
Since:
Starting from JDK 6.
Syntax:
java -XX:+DisableExplicitGC MainClass
Description:
Let us talk about Garbage Collector (GC), what is a Garbage Collector?
Garbage Collector is a way of the JVM to clean the memory and makes the java memory more efficient. It tracks (Mark step) and removes (sweep step) every unused object available in the JVM heap space. An object is considered unused when it’s referenced by null, assigned to another reference or by anonymous object. JVM introduced multiple flags that manages GC such as the flag "DisableExplicitGC”. Its main purpose is to prohibit the explicit execution of GC, and does not allow you to trigger GC through code with calling “System.gc()”. If this flag is enabled, then calling the function “System.gc()” will not have any effect.
Default Value:
This option is disabled by default.
Note:
This option can be useful when you want to force the developer to not trigger GC frequently in the code which may causes issues.
Errors:
None.
Related Posts:
Edit your Comment