$ jcmd 21844 GC.class_stats
21844:
WARNING: Ran out of C-heap; undercounted 368 total instances in data below
Index Super InstBytes KlassBytes annotations CpAll MethodCount Bytecodes MethodAll ROAll RWAll Total ClassName
1 -1 3176392 512 0 0 0 0 0 24 624 648 [I
2 -1 339752 512 0 0 0 0 0 24 624 648 [B
3 35 169128 680 136 17024 123 5375 33856 23816 29856 53672 java.lang.String
4 35 157488 784 0 23424 148 5833 38424 29096 36176 65272 java.lang.Class
[...]
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.