This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have set the max heap size for my java program to 512m, by specifying java -Xmx512m. However, when I run a test program that invokes java.lang.Runtime.maxMemory(), which is the amount of memory that the JVM will attempt to use, I don't see 512m, instead I only see about 510MB. How does one explain the difference ?
But I don't have any answer to the initial question. Turns out to be another reported bug: Bug Id 4391499: java.lang.Runtime.maxMemory() returns value different from -Xmx option. However, Sun set the status to "closed, will not be fixed" with the following explanation: Not a bug. The interpretation of the -Xmx flag is VM-dependent. Some VMs, including HotSpot, enforce a lower bound on the effective value of this option.