JDK-4391499 : java.lang.Runtime.maxMemory() returns value different from -Xmx option
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2000-11-21
  • Updated: 2001-07-17
  • Resolved: 2001-07-16
Description
----- from CCC proposal for maxMemory() ---------
If the implementation-dependent -Xmx flag is used then this method will return that value.
-------------------------------------------------

The results of a simple programe that just prints Runtime.getRuntime().maxMemory() are:

11 % java -Xmx1024k memory
maxMemory is :4194304

12 % java -Xmx2048k memory
maxMemory is :4194304

13 % java -Xmx4096k memory
maxMemory is :4194304

14 % java -Xmx6000k memory
maxMemory is :8388608

15 % java -Xmx8192k memory     
maxMemory is :8388608

These result shows that maxMemory is returning different values than what has been set at command line by -Xmx option.

Comments
EVALUATION 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. The CCC proposal should not have mentioned the -Xmx flag in this way. -- mr@eng 2001/7/16
07-09-0182