os::Bsd::initialize_system_info() sets _physical_memory too large

XMLWordPrintable

    • b17

        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[0] = CTL_HW;
          mib[1] = 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

              Assignee:
              Bengt Rutisson (Inactive)
              Reporter:
              Bengt Rutisson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: