author | coleenp |
Fri, 23 Mar 2012 11:16:05 -0400 | |
changeset 12263 | d20640f4f8fe |
parent 9623 | 151c0b638488 |
child 13728 | 882756847a04 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4459
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4459
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4459
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_SERVICES_MEMORYSERVICE_HPP |
26 |
#define SHARE_VM_SERVICES_MEMORYSERVICE_HPP |
|
27 |
||
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "memory/generation.hpp" |
|
30 |
#include "runtime/handles.hpp" |
|
31 |
#include "services/memoryUsage.hpp" |
|
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
32 |
#include "gc_interface/gcCause.hpp" |
7397 | 33 |
|
1 | 34 |
// Forward declaration |
35 |
class MemoryPool; |
|
36 |
class MemoryManager; |
|
37 |
class GCMemoryManager; |
|
38 |
class CollectedHeap; |
|
39 |
class Generation; |
|
40 |
class DefNewGeneration; |
|
41 |
class PSYoungGen; |
|
42 |
class PSOldGen; |
|
43 |
class PSPermGen; |
|
44 |
class CodeHeap; |
|
45 |
class ContiguousSpace; |
|
46 |
class CompactibleFreeListSpace; |
|
47 |
class PermanentGenerationSpec; |
|
48 |
class GenCollectedHeap; |
|
49 |
class ParallelScavengeHeap; |
|
50 |
class CompactingPermGenGen; |
|
51 |
class CMSPermGenGen; |
|
4459
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
52 |
class G1CollectedHeap; |
1 | 53 |
|
54 |
// VM Monitoring and Management Support |
|
55 |
||
56 |
class MemoryService : public AllStatic { |
|
57 |
private: |
|
58 |
enum { |
|
59 |
init_pools_list_size = 10, |
|
60 |
init_managers_list_size = 5 |
|
61 |
}; |
|
62 |
||
63 |
// index for minor and major generations |
|
64 |
enum { |
|
65 |
minor = 0, |
|
66 |
major = 1, |
|
67 |
n_gens = 2 |
|
68 |
}; |
|
69 |
||
70 |
static GrowableArray<MemoryPool*>* _pools_list; |
|
71 |
static GrowableArray<MemoryManager*>* _managers_list; |
|
72 |
||
73 |
// memory managers for minor and major GC statistics |
|
74 |
static GCMemoryManager* _major_gc_manager; |
|
75 |
static GCMemoryManager* _minor_gc_manager; |
|
76 |
||
77 |
// Code heap memory pool |
|
78 |
static MemoryPool* _code_heap_pool; |
|
79 |
||
80 |
static void add_generation_memory_pool(Generation* gen, |
|
81 |
MemoryManager* major_mgr, |
|
82 |
MemoryManager* minor_mgr); |
|
83 |
static void add_generation_memory_pool(Generation* gen, |
|
84 |
MemoryManager* major_mgr) { |
|
85 |
add_generation_memory_pool(gen, major_mgr, NULL); |
|
86 |
} |
|
87 |
||
88 |
static void add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen, |
|
89 |
MemoryManager* mgr); |
|
90 |
static void add_cms_perm_gen_memory_pool(CMSPermGenGen* perm_gen, |
|
91 |
MemoryManager* mgr); |
|
92 |
||
93 |
static void add_psYoung_memory_pool(PSYoungGen* gen, |
|
94 |
MemoryManager* major_mgr, |
|
95 |
MemoryManager* minor_mgr); |
|
96 |
static void add_psOld_memory_pool(PSOldGen* gen, |
|
97 |
MemoryManager* mgr); |
|
98 |
static void add_psPerm_memory_pool(PSPermGen* perm, |
|
99 |
MemoryManager* mgr); |
|
100 |
||
4459
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
101 |
static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
102 |
MemoryManager* major_mgr, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
103 |
MemoryManager* minor_mgr); |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
104 |
static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
105 |
MemoryManager* mgr); |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
106 |
static void add_g1PermGen_memory_pool(G1CollectedHeap* g1h, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
107 |
MemoryManager* mgr); |
1 | 108 |
|
109 |
static MemoryPool* add_space(ContiguousSpace* space, |
|
110 |
const char* name, |
|
111 |
bool is_heap, |
|
112 |
size_t max_size, |
|
113 |
bool support_usage_threshold); |
|
114 |
static MemoryPool* add_survivor_spaces(DefNewGeneration* gen, |
|
115 |
const char* name, |
|
116 |
bool is_heap, |
|
117 |
size_t max_size, |
|
118 |
bool support_usage_threshold); |
|
119 |
static MemoryPool* add_gen(Generation* gen, |
|
120 |
const char* name, |
|
121 |
bool is_heap, |
|
122 |
bool support_usage_threshold); |
|
123 |
static MemoryPool* add_cms_space(CompactibleFreeListSpace* space, |
|
124 |
const char* name, |
|
125 |
bool is_heap, |
|
126 |
size_t max_size, |
|
127 |
bool support_usage_threshold); |
|
128 |
||
129 |
static void add_gen_collected_heap_info(GenCollectedHeap* heap); |
|
130 |
static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap); |
|
4459
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
131 |
static void add_g1_heap_info(G1CollectedHeap* g1h); |
1 | 132 |
|
133 |
public: |
|
134 |
static void set_universe_heap(CollectedHeap* heap); |
|
135 |
static void add_code_heap_memory_pool(CodeHeap* heap); |
|
136 |
||
137 |
static MemoryPool* get_memory_pool(instanceHandle pool); |
|
138 |
static MemoryManager* get_memory_manager(instanceHandle mgr); |
|
139 |
||
140 |
static const int num_memory_pools() { |
|
141 |
return _pools_list->length(); |
|
142 |
} |
|
143 |
static const int num_memory_managers() { |
|
144 |
return _managers_list->length(); |
|
145 |
} |
|
146 |
||
147 |
static MemoryPool* get_memory_pool(int index) { |
|
148 |
return _pools_list->at(index); |
|
149 |
} |
|
150 |
||
151 |
static MemoryManager* get_memory_manager(int index) { |
|
152 |
return _managers_list->at(index); |
|
153 |
} |
|
154 |
||
155 |
static void track_memory_usage(); |
|
156 |
static void track_code_cache_memory_usage() { |
|
157 |
track_memory_pool_usage(_code_heap_pool); |
|
158 |
} |
|
159 |
static void track_memory_pool_usage(MemoryPool* pool); |
|
160 |
||
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
161 |
static void gc_begin(bool fullGC, bool recordGCBeginTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
162 |
bool recordAccumulatedGCTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
163 |
bool recordPreGCUsage, bool recordPeakUsage); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
164 |
static void gc_end(bool fullGC, bool recordPostGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
165 |
bool recordAccumulatedGCTime, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
166 |
bool recordGCEndTime, bool countCollection, |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
167 |
GCCause::Cause cause); |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
168 |
|
1 | 169 |
|
170 |
static void oops_do(OopClosure* f); |
|
171 |
||
172 |
static bool get_verbose() { return PrintGC; } |
|
173 |
static bool set_verbose(bool verbose); |
|
174 |
||
175 |
// Create an instance of java/lang/management/MemoryUsage |
|
176 |
static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS); |
|
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
177 |
|
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
178 |
static const GCMemoryManager* get_minor_gc_manager() { |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
179 |
return _minor_gc_manager; |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
180 |
} |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
181 |
|
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
182 |
static const GCMemoryManager* get_major_gc_manager() { |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
183 |
return _major_gc_manager; |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
184 |
} |
1 | 185 |
}; |
186 |
||
187 |
class TraceMemoryManagerStats : public StackObj { |
|
188 |
private: |
|
189 |
bool _fullGC; |
|
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
190 |
bool _recordGCBeginTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
191 |
bool _recordPreGCUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
192 |
bool _recordPeakUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
193 |
bool _recordPostGCUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
194 |
bool _recordAccumulatedGCTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
195 |
bool _recordGCEndTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
196 |
bool _countCollection; |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
197 |
GCCause::Cause _cause; |
1 | 198 |
public: |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
199 |
TraceMemoryManagerStats() {} |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
200 |
TraceMemoryManagerStats(bool fullGC, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
201 |
GCCause::Cause cause, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
202 |
bool recordGCBeginTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
203 |
bool recordPreGCUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
204 |
bool recordPeakUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
205 |
bool recordPostGCUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
206 |
bool recordAccumulatedGCTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
207 |
bool recordGCEndTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
208 |
bool countCollection = true); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
209 |
|
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
210 |
void initialize(bool fullGC, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
211 |
GCCause::Cause cause, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
212 |
bool recordGCBeginTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
213 |
bool recordPreGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
214 |
bool recordPeakUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
215 |
bool recordPostGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
216 |
bool recordAccumulatedGCTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
217 |
bool recordGCEndTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
218 |
bool countCollection); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
219 |
|
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
220 |
TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause); |
1 | 221 |
~TraceMemoryManagerStats(); |
222 |
}; |
|
7397 | 223 |
|
224 |
#endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP |