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

Improve consistency between actual values and MemoryUsage.used() in MBeans

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 13
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      gc

      Description

      There is inconsistent pair of values between actual values(seen from gc) and MemoryMXBeans(MemoryUsage.used()).

      The related code is:
      G1MonitoringSupport::recalculate_sizes() {
      ...
        _overall_used = _g1h->used_unlocked();
        _eden_space_used = _g1h->eden_regions_used_bytes();
      ...
        _old_gen_used = subtract_up_to_zero(_overall_used, _eden_space_used + _survivor_space_used);
      ...
      }
      and
      G1CollectedHeap::retire_mutator_alloc_region() {
      ...
        increase_used(allocated_bytes);
        _eden.add_used_bytes(allocated_bytes);
      ...
      }

      subtract_up_to_zero(size_t x, size_t y) {
          if (x > y) {
            return x - y;
          } else {
            return 0;
          }

      subtract_up_to_zero() is used prevent followed assert failure because of inconsistent values.

      Popped up during the review of JDK-8218049.

      Kim Barrett suggested using Double buffering or GlobalCounter.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              sangheki Sangheon Kim
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: