org.sonar.l10n.java.rules.squid.S1215.html Maven / Gradle / Ivy
The newest version!
Calling System.gc()
or Runtime.getRuntime().gc()
is a bad idea for a simple reason:
there is no way to know exactly what will be done under the hood by the JVM because the behavior will depend on its vendor, version and options:
- Will the whole application be frozen during the call?
- Is the -XX:DisableExplicitGC option activated?
- Will the JVM simply ignore the call?
- ...
An application relying on those unpredictable methods is also unpredictable and therefore broken.
The task of running the garbage collector should be left exclusively to the JVM.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy