A garbage collection is requested from code
What it finds
System.gc() asks for a full garbage collection. The collector knows better when to run, a forced collection can stop every thread for a long time, and with -XX:+DisableExplicitGC the call does nothing at all, so code that relies on it behaves differently from one deployment to the next.
From the rule's source, explicit_gc.rs.
class Memory { void clean() { System.gc();tx0 reports: a garbage collection is forced here Runtime.getRuntime().gc();tx0 reports: a garbage collection is forced here }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:explicit-gc" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:explicit-gc] reason="..."tx0 explain tx0/java:explicit-gc shows the same in the terminal. Found a false positive? Report it.