Reputation: 432
I have seen other questions on here like: How is the default max Java heap size determined? and Understanding java heap
I run the command to see my heap size java -XX:+PrintFlagsFinal -version
and I get the output for MaxHeapSize:
uintx MaxHeapSize := 0 {product}
What does this mean?
Upvotes: 3
Views: 2083
Reputation: 98284
This is a bug in JDK 8.
MaxHeapSize
is defined in HotSpot sources as uintx
, which stands for 64-bit unsigned integer.
In JDK 8, the format for printing uintx
flag values is "%-16lu"
, which treats input as unsigned long
.
However, the size of C++ unsigned long
differs on Windows and Unix:
unsigned long
is 64 bit.unsigned long
is 32 bit.So, JDK 8 on Windows prints only low 32 bits of uintx
flags. That's why if MaxHeapSize
is an exact multiple of 4 GiB, you'll see uintx MaxHeapSize := 0
. This is just the printing error; the actual max heap size is correct.
The bug was fixed in JDK 9 as a part of JDK-8042893 change:
} else if (is_uintx()) {
- st->print("%-16lu", get_uintx());
+ st->print(UINTX_FORMAT_W(-16), get_uintx());
Upvotes: 6