Reported by Chris Dennis on the jdk7u mailing list "I believe that when the Mac OS X support was merged in to the jdk7u-dev forest that a mistake was made regarding Visual Studio's lack of inttypes.h. The symptom of this bug can be seen in the following output: $ java -showversion -d64 -XX:MaxDirectMemorySize=4g OffHeapAllocationTest java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) Command Line: [-XX:MaxDirectMemorySize=4g] sun.misc.VM.maxDirectMemory() = 0 java.nio.Bits.maxMemory = 0 Experimenting with different MaxDirectMemorySize values clearly shows this to be a 32-bit wrap-around issue. When Mac OS X support was merged in, the INTX_FORMAT which is used to write the MaxDirectMemorySize global in to the system properties was modified to use PRIdPTR from inttypes.h. As Visual Studio lacks inttypes.h, definitions for this (and the other associated format specifiers) were added to globalDefinitions_visCPP.hpp. However the definitions added are only correct for a 32-bit system. I believe the following changeset corrects that error (no Windows access prevents me from verifying this fix however)." Reproducer public class TestMaxDirectMemory { public static void main(String[] args) { System.out.println(sun.misc.VM.maxDirectMemory()); } } When run with -XX:MaxDirectMemorySize=4g on a 64bit Windows 1.7.0_04 VM it will print 0 since the high 32bits will get dropped.
|