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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • hotspot
    • gc
    • b96

      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.

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

              Created:
              Updated:
              Resolved: