Reputation: 4429
I start my program by specifying the max memory to 128MB
java -Xmx128M ...
Then I connect to the jvm instance with jconsole. In the "VM Summary" tab, I found that:
Maximum heap size: 127,808 kbytes
This value is smaller than the one I specified in command line. Can any one give me some tips on this?
Upvotes: 0
Views: 977
Reputation: 15925
To quote the following Java bug report:
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.
Upvotes: 0
Reputation: 49351
I checked the value that is reported by Java Visual VM. It is exactly what I configured as JVM argument:
Example
JVM argument: 1024m
Heap Max: 1.073.741.824 B
So I guess jconsole has a special kind of calculation or Java Visual VM adjusts the value to the configured JVM argument - who knows?
Upvotes: 2
Reputation: 533790
I have found the exact memory size to be slightly smaller. How much smaller apepars to vary based on the version of Java and the OS. I suspect there is some implementation reasons why its is not precisely what you asked for.
BTW: This is only the maximum of the heap size. There are many other memory areas e.g. thread stack, direct memory, perm gen, shared libraries, native resources and memory mapped files which are not included so I wouldn't woory too much about it i.e. as there is a good margin of error between this value and the maximum memory the application will use.
BTW2: A maximum of 128m is rather small these days. Is there a good reason for it to be so small?
Upvotes: 1