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

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

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • tbd
    • 13
    • hotspot
    • None
    • 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

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

              Dates

                Created:
                Updated: