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

Introduce CollectedHeap::unused()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 13
    • Fix Version/s: 13
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      gc
    • Resolved In Build:
      b19

      Description

      JVM_FreeMemory() has two problems:

      1) It currently uses Heap_lock to protect capacity() and used() from changing while calculating the amount of free memory available. However, Heap_lock is doesn't protect capacity() and used() in all collectors, and as a result, JVM_FreeMemory() could return a negative value.

      2) The amount of free memory is not always calculated using capacity() - used(). For ZGC, we also want to take the reserve into account.

      The proposed solution is to introduce CollectedHeap::unused() (the name is chosen to match CollectedHeap::used()), so that we can delegate this calculation to the GC.

        Attachments

          Activity

            People

            Assignee:
            pliden Per Liden
            Reporter:
            pliden Per Liden
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: