Created
January 21, 2017 11:18
-
-
Save sinewalker/84778fe3271a63a85c9cc386d7d48898 to your computer and use it in GitHub Desktop.
Java MaxMemory
This file contains hidden or 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
| // See my answer to Stack Overflow: Maximum java heap size of a 32-bit JVM on a 64-bit host | |
| // http://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os/7019624#7019624 | |
| // and my blog: http://milosophical.me/blog/2007/03/04/32-bit-windows-and-jvm-virtual-memory-limit.html | |
| public class MaxMemory { | |
| public static void main(String[] args) { | |
| Runtime rt = Runtime.getRuntime(); | |
| long totalMem = rt.totalMemory(); | |
| long maxMem = rt.maxMemory(); | |
| long freeMem = rt.freeMemory(); | |
| double megs = 1048576.0; | |
| System.out.println ("Total Memory: " + totalMem + " (" + (totalMem/megs) + " MiB)"); | |
| System.out.println ("Max Memory: " + maxMem + " (" + (maxMem/megs) + " MiB)"); | |
| System.out.println ("Free Memory: " + freeMem + " (" + (freeMem/megs) + " MiB)"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment