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

Incorrect warning message in jcmd GC.class_histogram because of CDS

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: tbd
    • Component/s: core-svc
    • Labels:

      Description

      The warning message is:
      WARNING: Ran out of C-heap; undercounted 26 total instances in data below

      but we didn't run out of C-heap.

      The code path is:
          size_t missed_count = populate_table(&cit);
          if (missed_count != 0) {
            st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT
                         " total instances in data below",
                         missed_count);
          }
      ---
      size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter) {
        ResourceMark rm;

        RecordInstanceClosure ric(cit, filter);
        Universe::heap()->object_iterate(&ric);
        return ric.missed_count();
      }
      ---
        void do_object(oop obj) {
          if (should_visit(obj)) {
            if (!_cit->record_instance(obj)) {
              _missed_count++;
            }
          }
        }
      ---
      bool KlassInfoTable::record_instance(const oop obj) {
        Klass* k = obj->klass();
        KlassInfoEntry* elt = lookup(k);
        // elt may be NULL if it's a new klass for which we
        // could not allocate space for a new entry in the hashtable.
        if (elt != NULL) {
          elt->set_count(elt->count() + 1);
          elt->set_words(elt->words() + obj->size());
          _size_of_instances_in_words += obj->size();
          return true;
        } else {
          return false;
        }
      }
      ---
      KlassInfoEntry* KlassInfoTable::lookup(Klass* k) {
        uint idx = hash(k) % _num_buckets;
        assert(_buckets != NULL, "Allocation failure should have been caught");
        KlassInfoEntry* e = _buckets[idx].lookup(k);
        // Lookup may fail if this is a new klass for which we
        // could not allocate space for an new entry, or if it's
        // an archived class that we haven't loaded yet.
        assert(e == NULL || k == e->klass(), "must be equal");
        return e;
      }

      See the last comment.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                stefank Stefan Karlsson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: