Profile Image
vishnupriya

What is JVM startup parameter: -XX:+DisableExplicitGC?

What is JVM startup parameter: -XX:+DisableExplicitGC? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-disableexplicitgc

  • x-disableexplicitgc

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

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:

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-disableexplicitgc

  • x-disableexplicitgc

  • JVM startup parameter