Explicit Garbage Collection Call
Description
Calling `gc` suggests to the JVM that the garbage collector should be run, and memory should be reclaimed. This is only a suggestion, and there is no guarantee that anything will happen. Relying on this behavior for correctness or memory management is an anti-pattern.
Examples
Insecure Code
java
System.gc();Secure Code
java
Remediation
Remove explicit calls to `System.gc()` or `Runtime.getRuntime().gc()` and rely on the JVM's automatic garbage collection.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0263 |
| Category | Generic |
| Severity | LOW |
| CWE | |
| Confidence | HIGH |
| Impact | LOW |
| Likelihood | HIGH |
| Exploitability | COMPLEX |
| Tags | best-practice, audit |
| OWASP | N/A |