Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8138681

Runtime.getFreeMemory() reports wrong value after humongous allocation.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
      gc
    • Resolved In Build:
      b96

      Description

      Runtime.getRuntime().getFreeMemory() returns wrong value after humongous allocations.

      Humongous objects (objects which size is larger than a half of g1 region) take a whole number of regions.
      No other allocations are allowed in humongous regions.
      So if we allocate a smallest humongous object of size = (RegionSize/2 +1) it takes a whole region.
      Therefore free memory should decrease on one G1 Region size.
      Currently it decreases on exact object size which contradicts with javadoc on getFreeMemory():
      "an approximation to the total amount of memory currently available for future allocated objects, measured in bytes".

      MemoryMXBean returns right value on first humongous allocation but wrong values for next ones.

      Testcase attached.

        Attachments

          Activity

            People

            • Assignee:
              david David Lindholm (Inactive)
              Reporter:
              kzhaldyb Kirill Zhaldybin (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: