Created
April 9, 2014 14:35
-
-
Save arnobroekhof/10277659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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