src/share/vm/memory/heapInspection.cpp

Print this page
rev 4462 : 8012086: The object count event should only send events for instances occupying more than 0.5% of the heap

*** 111,123 **** delete elt; elt = next; } } ! KlassInfoTable::KlassInfoTable(HeapWord* ref) { ! _size = 0; ! _ref = ref; _buckets = (KlassInfoBucket *) os::malloc(sizeof(KlassInfoBucket) * _num_buckets, mtInternal); if (_buckets != NULL) { _size = _num_buckets; for (int index = 0; index < _size; index++) { _buckets[index].initialize(); --- 111,122 ---- delete elt; elt = next; } } ! KlassInfoTable::KlassInfoTable(HeapWord* ref) : ! _size(0), _ref(ref), _size_of_instances_in_words(0) { _buckets = (KlassInfoBucket *) os::malloc(sizeof(KlassInfoBucket) * _num_buckets, mtInternal); if (_buckets != NULL) { _size = _num_buckets; for (int index = 0; index < _size; index++) { _buckets[index].initialize();
*** 158,167 **** --- 157,167 ---- // 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; } }
*** 171,180 **** --- 171,184 ---- for (int index = 0; index < _size; index++) { _buckets[index].iterate(cic); } } + size_t KlassInfoTable::size_of_instances_in_words() const { + return _size_of_instances_in_words; + } + int KlassInfoHisto::sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2) { return (*e1)->compare(*e1,*e2); } KlassInfoHisto::KlassInfoHisto(const char* title) :
*** 280,302 **** SharedHeap* sh = SharedHeap::heap(); sh->gc_epilogue(false /* !full */); // release all acquired locks, etc. } } ! size_t HeapInspection::instance_inspection(KlassInfoTable* cit, ! KlassInfoClosure* cl, bool need_prologue, ! BoolObjectClosure* filter) { ResourceMark rm; if (need_prologue) { prologue(); } RecordInstanceClosure ric(cit, filter); Universe::heap()->object_iterate(&ric); - cit->iterate(cl); // need to run epilogue if we run prologue if (need_prologue) { epilogue(); } --- 284,304 ---- SharedHeap* sh = SharedHeap::heap(); sh->gc_epilogue(false /* !full */); // release all acquired locks, etc. } } ! size_t HeapInspection::populate_table(KlassInfoTable* cit, bool need_prologue, ! BoolObjectClosure *filter) { ResourceMark rm; if (need_prologue) { prologue(); } RecordInstanceClosure ric(cit, filter); Universe::heap()->object_iterate(&ric); // need to run epilogue if we run prologue if (need_prologue) { epilogue(); }
*** 307,327 **** void HeapInspection::heap_inspection(outputStream* st, bool need_prologue) { ResourceMark rm; KlassInfoTable cit(start_of_perm_gen()); if (!cit.allocation_failed()) { ! KlassInfoHisto histo("\n" ! " num #instances #bytes class name\n" ! "----------------------------------------------"); ! HistoClosure hc(&histo); ! ! size_t missed_count = instance_inspection(&cit, &hc, need_prologue); if (missed_count != 0) { st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT " total instances in data below", missed_count); } histo.sort(); histo.print_on(st); } else { st->print_cr("WARNING: Ran out of C-heap; histogram not generated"); } --- 309,332 ---- void HeapInspection::heap_inspection(outputStream* st, bool need_prologue) { ResourceMark rm; KlassInfoTable cit(start_of_perm_gen()); if (!cit.allocation_failed()) { ! size_t missed_count = populate_table(&cit, need_prologue); if (missed_count != 0) { st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT " total instances in data below", missed_count); } + + KlassInfoHisto histo("\n" + " num #instances #bytes class name\n" + "----------------------------------------------"); + HistoClosure hc(&histo); + + cit.iterate(&hc); + histo.sort(); histo.print_on(st); } else { st->print_cr("WARNING: Ran out of C-heap; histogram not generated"); }