1 MB = ? Bytes

I have a constant for Megabate that is 1024 * 1024. However, when I print the max Runtime.maxMemory() divided by this constant, i get 63 MB instead of 64 MB (as the default Xmx value).
[191 byte] By [MartinHilpert] at [2007-9-30 19:49:54]
# 1
What do you get if you just print Runtime.maxMemory()?
YATArchivist at 2007-7-7 0:37:27 > top of Java-index,Other Topics,Algorithms...
# 2
Hi,1MB = 2^20 Byte = 1048576 Bytes64 MB = 2^26 Bytes = 67108864 BytesSystem.out.println(Runtime.getRuntime().maxMemory()); says I have 66650112 Bytes of Memory.66650112 / 1048576 = 63Does this help?Lost Crumb
lost_crumb at 2007-7-7 0:37:27 > top of Java-index,Other Topics,Algorithms...
# 3
Hm, so when i start Java with "java -Xmx64m" this doesn't mean that i have "full" 64 megabytes ( 67108864 Bytes)? Or does the JVM translate this "64m" wrongly?
MartinHilpert at 2007-7-7 0:37:27 > top of Java-index,Other Topics,Algorithms...
# 4

I tested with -Xmx1024m -server in SUN jdk 1.4.2

Runtime.getRuntime().maxMemory() returns a value that is slightly more than 11 MB less than 1 GB

My guess would be that some of the memory is set aside for other purposes inside the JVM.

The SUN documentation for the -Xmx whitch says that it sets the max size of the "memory allocation pool" it does not promise any specific split between heap, stack, jvm internal use, heap and stack for sun classes etc.

tychoS at 2007-7-7 0:37:27 > top of Java-index,Other Topics,Algorithms...
# 5

> The SUN documentation for the -Xmx whitch says that it sets the max size of the "memory allocation pool" it does not

> promise any specific split between heap, stack, jvm internal use, heap and stack for sun classes etc.

Really? java -X

<snip>

-Xms<size>set initial Java heap size

-Xmx<size>set maximum Java heap size

-Xss<size>set java thread stack size

The values for -Xmx64M posted give 63.5625 (63 9/16), rather than 63: I was wondering whether integer division was to blame and the answer is "partially". The overall answer seems to be that the documentation is inconsistent.

YATArchivist at 2007-7-7 0:37:27 > top of Java-index,Other Topics,Algorithms...