Skip to content

Instantly share code, notes, and snippets.

@vaskokj
Created October 1, 2014 19:04
Show Gist options
  • Save vaskokj/ef51682663b169566eb7 to your computer and use it in GitHub Desktop.
Save vaskokj/ef51682663b169566eb7 to your computer and use it in GitHub Desktop.
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("##### Heap utilization statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment