< prev index next >

src/hotspot/share/memory/heapInspection.cpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.inline.hpp"
  27 #include "classfile/classLoaderDataGraph.hpp"
  28 #include "classfile/moduleEntry.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "gc/shared/collectedHeap.hpp"


  31 #include "memory/heapInspection.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "memory/universe.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/reflectionAccessorImplKlassHelper.hpp"
  36 #include "runtime/os.hpp"
  37 #include "utilities/globalDefinitions.hpp"
  38 #include "utilities/macros.hpp"
  39 #include "utilities/stack.inline.hpp"
  40 
  41 // HeapInspection
  42 
  43 inline KlassInfoEntry::~KlassInfoEntry() {
  44   if (_subclasses != NULL) {
  45     delete _subclasses;
  46   }
  47 }
  48 
  49 inline void KlassInfoEntry::add_subclass(KlassInfoEntry* cie) {
  50   if (_subclasses == NULL) {


 495 
 496   size_t missed_count() { return _missed_count; }
 497 
 498  private:
 499   bool should_visit(oop obj) {
 500     return _filter == NULL || _filter->do_object_b(obj);
 501   }
 502 };
 503 
 504 size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter) {
 505   ResourceMark rm;
 506 
 507   RecordInstanceClosure ric(cit, filter);
 508   Universe::heap()->object_iterate(&ric);
 509   return ric.missed_count();
 510 }
 511 
 512 void HeapInspection::heap_inspection(outputStream* st) {
 513   ResourceMark rm;
 514 
 515   KlassInfoTable cit(true);
 516   if (!cit.allocation_failed()) {
 517     // populate table with object allocation info
 518     size_t missed_count = populate_table(&cit);
 519     if (missed_count != 0) {
 520       st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT
 521                    " total instances in data below",
 522                    missed_count);
 523     }
 524 
 525     // Sort and print klass instance info
 526     KlassInfoHisto histo(&cit);
 527     HistoClosure hc(&histo);
 528 
 529     cit.iterate(&hc);
 530 
 531     histo.sort();
 532     histo.print_histo_on(st);
 533   } else {
 534     st->print_cr("ERROR: Ran out of C-heap; histogram not generated");
 535   }
 536   st->flush();
 537 }
 538 
 539 class FindInstanceClosure : public ObjectClosure {
 540  private:




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.inline.hpp"
  27 #include "classfile/classLoaderDataGraph.hpp"
  28 #include "classfile/moduleEntry.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "gc/shared/collectedHeap.hpp"
  31 #include "logging/log.hpp"
  32 #include "logging/logTag.hpp"
  33 #include "memory/heapInspection.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "memory/universe.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "oops/reflectionAccessorImplKlassHelper.hpp"
  38 #include "runtime/os.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 #include "utilities/macros.hpp"
  41 #include "utilities/stack.inline.hpp"
  42 
  43 // HeapInspection
  44 
  45 inline KlassInfoEntry::~KlassInfoEntry() {
  46   if (_subclasses != NULL) {
  47     delete _subclasses;
  48   }
  49 }
  50 
  51 inline void KlassInfoEntry::add_subclass(KlassInfoEntry* cie) {
  52   if (_subclasses == NULL) {


 497 
 498   size_t missed_count() { return _missed_count; }
 499 
 500  private:
 501   bool should_visit(oop obj) {
 502     return _filter == NULL || _filter->do_object_b(obj);
 503   }
 504 };
 505 
 506 size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter) {
 507   ResourceMark rm;
 508 
 509   RecordInstanceClosure ric(cit, filter);
 510   Universe::heap()->object_iterate(&ric);
 511   return ric.missed_count();
 512 }
 513 
 514 void HeapInspection::heap_inspection(outputStream* st) {
 515   ResourceMark rm;
 516 
 517   KlassInfoTable cit(false);
 518   if (!cit.allocation_failed()) {
 519     // populate table with object allocation info
 520     size_t missed_count = populate_table(&cit);
 521     if (missed_count != 0) {
 522       log_info(gc, classhisto)("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT
 523                                " total instances in data below",
 524                                missed_count);
 525     }
 526 
 527     // Sort and print klass instance info
 528     KlassInfoHisto histo(&cit);
 529     HistoClosure hc(&histo);
 530 
 531     cit.iterate(&hc);
 532 
 533     histo.sort();
 534     histo.print_histo_on(st);
 535   } else {
 536     st->print_cr("ERROR: Ran out of C-heap; histogram not generated");
 537   }
 538   st->flush();
 539 }
 540 
 541 class FindInstanceClosure : public ObjectClosure {
 542  private:


< prev index next >