Print this page
rev 4524 : 8012086: The object count event should only send events for instances occupying more than 0.5% of the heap
Reviewed-by: brutisso, jwilhelm
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/memory/heapInspection.hpp
+++ new/src/share/vm/memory/heapInspection.hpp
1 1 /*
2 2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP
26 26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP
27 27
28 28 #include "memory/allocation.inline.hpp"
29 +#include "memory/klassInfoClosure.hpp"
29 30 #include "oops/oop.inline.hpp"
30 31
31 32
32 33 // HeapInspection
33 34
34 35 // KlassInfoTable is a bucket hash table that
35 36 // maps klassOops to extra information:
36 37 // instance count and instance word size.
37 38 //
38 39 // A KlassInfoBucket is the head of a link list
39 40 // of KlassInfoEntry's
40 41 //
41 42 // KlassInfoHisto is a growable array of pointers
42 43 // to KlassInfoEntry's and is used to sort
43 44 // the entries.
44 45
45 46 class KlassInfoEntry: public CHeapObj<mtInternal> {
46 47 private:
47 48 KlassInfoEntry* _next;
48 49 klassOop _klass;
49 50 long _instance_count;
50 51 size_t _instance_words;
51 52
52 53 public:
53 54 KlassInfoEntry(klassOop k, KlassInfoEntry* next) :
54 55 _klass(k), _instance_count(0), _instance_words(0), _next(next)
55 56 {}
56 57 KlassInfoEntry* next() { return _next; }
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
57 58 bool is_equal(klassOop k) { return k == _klass; }
58 59 klassOop klass() { return _klass; }
59 60 long count() { return _instance_count; }
60 61 void set_count(long ct) { _instance_count = ct; }
61 62 size_t words() { return _instance_words; }
62 63 void set_words(size_t wds) { _instance_words = wds; }
63 64 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
64 65 void print_on(outputStream* st) const;
65 66 };
66 67
67 -class KlassInfoClosure: public StackObj {
68 - public:
69 - // Called for each KlassInfoEntry.
70 - virtual void do_cinfo(KlassInfoEntry* cie) = 0;
71 -};
72 -
73 68 class KlassInfoBucket: public CHeapObj<mtInternal> {
74 69 private:
75 70 KlassInfoEntry* _list;
76 71 KlassInfoEntry* list() { return _list; }
77 72 void set_list(KlassInfoEntry* l) { _list = l; }
78 73 public:
79 74 KlassInfoEntry* lookup(const klassOop k);
80 75 void initialize() { _list = NULL; }
81 76 void empty();
82 77 void iterate(KlassInfoClosure* cic);
83 78 };
84 79
85 80 class KlassInfoTable: public StackObj {
86 81 private:
87 82 int _size;
88 83 static const int _num_buckets = 20011;
84 + size_t _size_of_instances_in_words;
89 85
90 86 // An aligned reference address (typically the least
91 87 // address in the perm gen) used for hashing klass
92 88 // objects.
93 89 HeapWord* _ref;
94 90
95 91 KlassInfoBucket* _buckets;
96 92 uint hash(klassOop p);
97 93 KlassInfoEntry* lookup(const klassOop k);
98 94
99 95 public:
100 96 KlassInfoTable(HeapWord* ref);
101 97 ~KlassInfoTable();
102 98 bool record_instance(const oop obj);
103 99 void iterate(KlassInfoClosure* cic);
104 100 bool allocation_failed() { return _buckets == NULL; }
101 + size_t size_of_instances_in_words() const;
105 102 };
106 103
107 104 class KlassInfoHisto : public StackObj {
108 105 private:
109 106 GrowableArray<KlassInfoEntry*>* _elements;
110 107 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; }
111 108 const char* _title;
112 109 const char* title() const { return _title; }
113 110 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2);
114 111 void print_elements(outputStream* st) const;
115 112 static const int _histo_initial_size = 1000;
116 113 public:
117 114 KlassInfoHisto(const char* title);
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
118 115 ~KlassInfoHisto();
119 116 void add(KlassInfoEntry* cie);
120 117 void print_on(outputStream* st) const;
121 118 void sort();
122 119 };
123 120
124 121
125 122 class HeapInspection : public AllStatic {
126 123 public:
127 124 static void heap_inspection(outputStream* st, bool need_prologue);
128 - static size_t instance_inspection(KlassInfoTable* cit,
129 - KlassInfoClosure* cl,
130 - bool need_prologue,
131 - BoolObjectClosure* filter = NULL);
125 + static size_t populate_table(KlassInfoTable* cit,
126 + bool need_prologue,
127 + BoolObjectClosure* filter = NULL);
132 128 static HeapWord* start_of_perm_gen();
133 129 static void find_instances_at_safepoint(klassOop k, GrowableArray<oop>* result);
134 130 private:
135 131 static bool is_shared_heap();
136 132 static void prologue();
137 133 static void epilogue();
138 134 };
139 135
140 136 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX