JVM MaxHeapSize := 0 - what does this mean?

Viewed 1118
1 Answers

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:

  • Most Unix-like systems are LP64, where the size of unsigned long is 64 bit.
  • Visual C++ on Windows is LLP64, where the size of 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());
Related