]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
SONARPLUGINS-1229 Display memory usage at the end of analysis
authorEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 15 Dec 2011 07:49:59 +0000 (07:49 +0000)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 15 Dec 2011 07:49:59 +0000 (07:49 +0000)
src/main/java/org/sonar/runner/Main.java

index 89157ccf153a157f0fb73e0b56e6d6ee5af1e218..eccf6d0909a0b0af3e67a23b1950212b928cb041 100644 (file)
@@ -52,9 +52,18 @@ public final class Main {
       runner.execute();
     } catch (IOException e) {
       throw new RuntimeException(e);
+    } finally {
+      printMemoryUsage();
     }
   }
 
+  private static final long MB = 1024 * 1024;
+
+  private static void printMemoryUsage() {
+    Runtime r = Runtime.getRuntime();
+    System.out.println("Final Memory: " + (r.totalMemory() - r.freeMemory()) / MB + "M/" + r.totalMemory() / MB + "M");
+  }
+
   static Properties loadProperties(String[] args) {
     Properties commandLineProps = new Properties();
     commandLineProps.putAll(System.getProperties());