UMC.GC

The "UMC Unwanted method calls" group of errors relates to some methods, such as System.exit() and System.gc() that might be unwanted. Debug print, such as System.out.println() and System.err.println(), might be unwanted as well. A UMC.GC warning appears if there is a call to the System.gc() method.

Vulnerability and risk

This method should only be used in performance-related testing procedure; otherwise the impact might be opposite of that expected.

Example 1

Copy
     String multiply(String x, int n) {
         if (n <= 0) return "";
         StringBuffer buf = new StringBuffer();
         while (n-- > 0) {
             buf.append(x);
         }
         return buf.toString();
     }
     String multiplyGc(String x, int n) {
         System.gc(); // see perfromance resutlts if run this test
         return multiply(x, n);
     }

UMC.GC is reported for line 19: The System.gc() method call is unwanted