Skip to content

Instantly share code, notes, and snippets.

@arnobroekhof
Created April 9, 2014 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnobroekhof/10277659 to your computer and use it in GitHub Desktop.
Save arnobroekhof/10277659 to your computer and use it in GitHub Desktop.
public abstract class Memory {
private static Runtime runtime = Runtime.getRuntime();
private static int mb = 1024*1024;
public static long getFree() {
return runtime.freeMemory() / mb;
}
public static long getUsed() {
return runtime.totalMemory() / - runtime.freeMemory() / mb;
}
public static long getTotal() {
return runtime.totalMemory() / mb;
}
public static long getAvailable() {
return runtime.maxMemory() / mb;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment