1 /* 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP 26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP 27 28 #include "memory/allocation.inline.hpp" 29 #include "oops/oop.inline.hpp" 30 31 #ifndef SERVICES_KERNEL 32 33 34 // HeapInspection 35 36 // KlassInfoTable is a bucket hash table that 37 // maps Klass*s to extra information: 38 // instance count and instance word size. 39 // 40 // A KlassInfoBucket is the head of a link list 41 // of KlassInfoEntry's 42 // 43 // KlassInfoHisto is a growable array of pointers 44 // to KlassInfoEntry's and is used to sort 45 // the entries. 46 47 class KlassInfoEntry: public CHeapObj<mtInternal> { 48 private: 49 KlassInfoEntry* _next; 50 Klass* _klass; 51 long _instance_count; 112 class KlassInfoHisto : public StackObj { 113 private: 114 GrowableArray<KlassInfoEntry*>* _elements; 115 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; } 116 const char* _title; 117 const char* title() const { return _title; } 118 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2); 119 void print_elements(outputStream* st) const; 120 public: 121 enum { 122 histo_initial_size = 1000 123 }; 124 KlassInfoHisto(const char* title, 125 int estimatedCount); 126 ~KlassInfoHisto(); 127 void add(KlassInfoEntry* cie); 128 void print_on(outputStream* st) const; 129 void sort(); 130 }; 131 132 #endif // SERVICES_KERNEL 133 134 class HeapInspection : public AllStatic { 135 public: 136 static void heap_inspection(outputStream* st, bool need_prologue) KERNEL_RETURN; 137 static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) KERNEL_RETURN; 138 }; 139 140 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP | 1 /* 2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP 26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP 27 28 #include "memory/allocation.inline.hpp" 29 #include "oops/oop.inline.hpp" 30 31 #if INCLUDE_SERVICES 32 33 34 // HeapInspection 35 36 // KlassInfoTable is a bucket hash table that 37 // maps Klass*s to extra information: 38 // instance count and instance word size. 39 // 40 // A KlassInfoBucket is the head of a link list 41 // of KlassInfoEntry's 42 // 43 // KlassInfoHisto is a growable array of pointers 44 // to KlassInfoEntry's and is used to sort 45 // the entries. 46 47 class KlassInfoEntry: public CHeapObj<mtInternal> { 48 private: 49 KlassInfoEntry* _next; 50 Klass* _klass; 51 long _instance_count; 112 class KlassInfoHisto : public StackObj { 113 private: 114 GrowableArray<KlassInfoEntry*>* _elements; 115 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; } 116 const char* _title; 117 const char* title() const { return _title; } 118 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2); 119 void print_elements(outputStream* st) const; 120 public: 121 enum { 122 histo_initial_size = 1000 123 }; 124 KlassInfoHisto(const char* title, 125 int estimatedCount); 126 ~KlassInfoHisto(); 127 void add(KlassInfoEntry* cie); 128 void print_on(outputStream* st) const; 129 void sort(); 130 }; 131 132 #endif // INCLUDE_SERVICES 133 134 class HeapInspection : public AllStatic { 135 public: 136 static void heap_inspection(outputStream* st, bool need_prologue) NOT_SERVICES_RETURN; 137 static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN; 138 }; 139 140 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP |