On my 8GB OSX laptop os::Bsd::initialize_system_info() sets up _physical_memory to be 140733629517824, which is 127TB.
Since we base for example the maximum Java heap size on os::physical_memory() which on BSD returns this value we get ~30GB max heap size even for just running "java -version".
Here is the code in os::Bsd::initialize_system_info() that returns a too large value:
mib = CTL_HW;
mib = HW_USERMEM;
len = sizeof(mem_val);
if (sysctl(mib, 2, &mem_val, &len, NULL, 0) != -1)
_physical_memory = mem_val;
Somehow the sysctl() call sets mem_val to 140733629517824.
Impact=Medium since we normally don't crash but just use up much more memory than necessary (we don't commit the maximum heap size, but there are several data structures that are O(MaxHeapSize) in size.
Likelihood: High. Seem to happen on all OSX machine where I've tried it.
Workaround: Low. Set -Xmx on the command line.
ILW=MHL -> P3