Mercurial > hg > graal-compiler
annotate src/share/vm/services/memoryService.cpp @ 7046:b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 27 Nov 2012 13:43:04 +0100 |
parents | da91efe96a93 |
children | db9981fd3124 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "classfile/vmSymbols.hpp" | |
28 #include "gc_implementation/shared/mutableSpace.hpp" | |
29 #include "memory/collectorPolicy.hpp" | |
30 #include "memory/defNewGeneration.hpp" | |
31 #include "memory/genCollectedHeap.hpp" | |
32 #include "memory/generation.hpp" | |
33 #include "memory/generationSpec.hpp" | |
34 #include "memory/heap.hpp" | |
35 #include "memory/memRegion.hpp" | |
36 #include "memory/tenuredGeneration.hpp" | |
37 #include "oops/oop.inline.hpp" | |
38 #include "runtime/javaCalls.hpp" | |
39 #include "services/classLoadingService.hpp" | |
40 #include "services/lowMemoryDetector.hpp" | |
41 #include "services/management.hpp" | |
42 #include "services/memoryManager.hpp" | |
43 #include "services/memoryPool.hpp" | |
44 #include "services/memoryService.hpp" | |
45 #include "utilities/growableArray.hpp" | |
46 #ifndef SERIALGC | |
47 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" | |
48 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" | |
49 #include "gc_implementation/parNew/parNewGeneration.hpp" | |
50 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" | |
51 #include "gc_implementation/parallelScavenge/psOldGen.hpp" | |
52 #include "gc_implementation/parallelScavenge/psYoungGen.hpp" | |
53 #include "services/g1MemoryPool.hpp" | |
54 #include "services/psMemoryPool.hpp" | |
55 #endif | |
0 | 56 |
57 GrowableArray<MemoryPool*>* MemoryService::_pools_list = | |
6197 | 58 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_pools_list_size, true); |
0 | 59 GrowableArray<MemoryManager*>* MemoryService::_managers_list = |
6197 | 60 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryManager*>(init_managers_list_size, true); |
0 | 61 |
62 GCMemoryManager* MemoryService::_minor_gc_manager = NULL; | |
63 GCMemoryManager* MemoryService::_major_gc_manager = NULL; | |
64 MemoryPool* MemoryService::_code_heap_pool = NULL; | |
65 | |
66 class GcThreadCountClosure: public ThreadClosure { | |
67 private: | |
68 int _count; | |
69 public: | |
70 GcThreadCountClosure() : _count(0) {}; | |
71 void do_thread(Thread* thread); | |
72 int count() { return _count; } | |
73 }; | |
74 | |
75 void GcThreadCountClosure::do_thread(Thread* thread) { | |
76 _count++; | |
77 } | |
78 | |
79 void MemoryService::set_universe_heap(CollectedHeap* heap) { | |
80 CollectedHeap::Name kind = heap->kind(); | |
81 switch (kind) { | |
82 case CollectedHeap::GenCollectedHeap : { | |
83 add_gen_collected_heap_info(GenCollectedHeap::heap()); | |
84 break; | |
85 } | |
86 #ifndef SERIALGC | |
87 case CollectedHeap::ParallelScavengeHeap : { | |
88 add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap()); | |
89 break; | |
90 } | |
342 | 91 case CollectedHeap::G1CollectedHeap : { |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
92 add_g1_heap_info(G1CollectedHeap::heap()); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
93 break; |
342 | 94 } |
0 | 95 #endif // SERIALGC |
96 default: { | |
342 | 97 guarantee(false, "Unrecognized kind of heap"); |
0 | 98 } |
99 } | |
100 | |
101 // set the GC thread count | |
102 GcThreadCountClosure gctcc; | |
103 heap->gc_threads_do(&gctcc); | |
104 int count = gctcc.count(); | |
105 if (count > 0) { | |
106 _minor_gc_manager->set_num_gc_threads(count); | |
107 _major_gc_manager->set_num_gc_threads(count); | |
108 } | |
109 | |
110 // All memory pools and memory managers are initialized. | |
111 // | |
112 _minor_gc_manager->initialize_gc_stat_info(); | |
113 _major_gc_manager->initialize_gc_stat_info(); | |
114 } | |
115 | |
116 // Add memory pools for GenCollectedHeap | |
117 // This function currently only supports two generations collected heap. | |
118 // The collector for GenCollectedHeap will have two memory managers. | |
119 void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) { | |
120 CollectorPolicy* policy = heap->collector_policy(); | |
121 | |
122 assert(policy->is_two_generation_policy(), "Only support two generations"); | |
123 guarantee(heap->n_gens() == 2, "Only support two-generation heap"); | |
124 | |
125 TwoGenerationCollectorPolicy* two_gen_policy = policy->as_two_generation_policy(); | |
126 if (two_gen_policy != NULL) { | |
127 GenerationSpec** specs = two_gen_policy->generations(); | |
128 Generation::Name kind = specs[0]->name(); | |
129 switch (kind) { | |
130 case Generation::DefNew: | |
131 _minor_gc_manager = MemoryManager::get_copy_memory_manager(); | |
132 break; | |
133 #ifndef SERIALGC | |
134 case Generation::ParNew: | |
135 case Generation::ASParNew: | |
136 _minor_gc_manager = MemoryManager::get_parnew_memory_manager(); | |
137 break; | |
138 #endif // SERIALGC | |
139 default: | |
140 guarantee(false, "Unrecognized generation spec"); | |
141 break; | |
142 } | |
143 if (policy->is_mark_sweep_policy()) { | |
144 _major_gc_manager = MemoryManager::get_msc_memory_manager(); | |
145 #ifndef SERIALGC | |
146 } else if (policy->is_concurrent_mark_sweep_policy()) { | |
147 _major_gc_manager = MemoryManager::get_cms_memory_manager(); | |
148 #endif // SERIALGC | |
149 } else { | |
150 guarantee(false, "Unknown two-gen policy"); | |
151 } | |
152 } else { | |
153 guarantee(false, "Non two-gen policy"); | |
154 } | |
155 _managers_list->append(_minor_gc_manager); | |
156 _managers_list->append(_major_gc_manager); | |
157 | |
158 add_generation_memory_pool(heap->get_gen(minor), _major_gc_manager, _minor_gc_manager); | |
159 add_generation_memory_pool(heap->get_gen(major), _major_gc_manager); | |
160 } | |
161 | |
162 #ifndef SERIALGC | |
163 // Add memory pools for ParallelScavengeHeap | |
164 // This function currently only supports two generations collected heap. | |
165 // The collector for ParallelScavengeHeap will have two memory managers. | |
166 void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) { | |
167 // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC. | |
168 _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager(); | |
169 _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager(); | |
170 _managers_list->append(_minor_gc_manager); | |
171 _managers_list->append(_major_gc_manager); | |
172 | |
173 add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); | |
174 add_psOld_memory_pool(heap->old_gen(), _major_gc_manager); | |
175 } | |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
176 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
177 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) { |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
178 assert(UseG1GC, "sanity"); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
179 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
180 _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager(); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
181 _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager(); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
182 _managers_list->append(_minor_gc_manager); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
183 _managers_list->append(_major_gc_manager); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
184 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
185 add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
186 add_g1OldGen_memory_pool(g1h, _major_gc_manager); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
187 } |
0 | 188 #endif // SERIALGC |
189 | |
190 MemoryPool* MemoryService::add_gen(Generation* gen, | |
191 const char* name, | |
192 bool is_heap, | |
193 bool support_usage_threshold) { | |
194 | |
195 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); | |
196 GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold); | |
197 _pools_list->append(pool); | |
198 return (MemoryPool*) pool; | |
199 } | |
200 | |
201 MemoryPool* MemoryService::add_space(ContiguousSpace* space, | |
202 const char* name, | |
203 bool is_heap, | |
204 size_t max_size, | |
205 bool support_usage_threshold) { | |
206 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); | |
207 ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold); | |
208 | |
209 _pools_list->append(pool); | |
210 return (MemoryPool*) pool; | |
211 } | |
212 | |
213 MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* gen, | |
214 const char* name, | |
215 bool is_heap, | |
216 size_t max_size, | |
217 bool support_usage_threshold) { | |
218 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); | |
219 SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(gen, name, type, max_size, support_usage_threshold); | |
220 | |
221 _pools_list->append(pool); | |
222 return (MemoryPool*) pool; | |
223 } | |
224 | |
225 #ifndef SERIALGC | |
226 MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space, | |
227 const char* name, | |
228 bool is_heap, | |
229 size_t max_size, | |
230 bool support_usage_threshold) { | |
231 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); | |
232 CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold); | |
233 _pools_list->append(pool); | |
234 return (MemoryPool*) pool; | |
235 } | |
236 #endif // SERIALGC | |
237 | |
238 // Add memory pool(s) for one generation | |
239 void MemoryService::add_generation_memory_pool(Generation* gen, | |
240 MemoryManager* major_mgr, | |
241 MemoryManager* minor_mgr) { | |
242 Generation::Name kind = gen->kind(); | |
243 int index = _pools_list->length(); | |
244 | |
245 switch (kind) { | |
246 case Generation::DefNew: { | |
247 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); | |
248 DefNewGeneration* young_gen = (DefNewGeneration*) gen; | |
249 // Add a memory pool for each space and young gen doesn't | |
250 // support low memory detection as it is expected to get filled up. | |
251 MemoryPool* eden = add_space(young_gen->eden(), | |
252 "Eden Space", | |
253 true, /* is_heap */ | |
254 young_gen->max_eden_size(), | |
255 false /* support_usage_threshold */); | |
256 MemoryPool* survivor = add_survivor_spaces(young_gen, | |
257 "Survivor Space", | |
258 true, /* is_heap */ | |
259 young_gen->max_survivor_size(), | |
260 false /* support_usage_threshold */); | |
261 break; | |
262 } | |
263 | |
264 #ifndef SERIALGC | |
265 case Generation::ParNew: | |
266 case Generation::ASParNew: | |
267 { | |
268 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); | |
269 // Add a memory pool for each space and young gen doesn't | |
270 // support low memory detection as it is expected to get filled up. | |
271 ParNewGeneration* parnew_gen = (ParNewGeneration*) gen; | |
272 MemoryPool* eden = add_space(parnew_gen->eden(), | |
273 "Par Eden Space", | |
274 true /* is_heap */, | |
275 parnew_gen->max_eden_size(), | |
276 false /* support_usage_threshold */); | |
277 MemoryPool* survivor = add_survivor_spaces(parnew_gen, | |
278 "Par Survivor Space", | |
279 true, /* is_heap */ | |
280 parnew_gen->max_survivor_size(), | |
281 false /* support_usage_threshold */); | |
282 | |
283 break; | |
284 } | |
285 #endif // SERIALGC | |
286 | |
287 case Generation::MarkSweepCompact: { | |
288 assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); | |
289 add_gen(gen, | |
290 "Tenured Gen", | |
291 true, /* is_heap */ | |
292 true /* support_usage_threshold */); | |
293 break; | |
294 } | |
295 | |
296 #ifndef SERIALGC | |
297 case Generation::ConcurrentMarkSweep: | |
298 case Generation::ASConcurrentMarkSweep: | |
299 { | |
300 assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); | |
301 ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen; | |
302 MemoryPool* pool = add_cms_space(cms->cmsSpace(), | |
303 "CMS Old Gen", | |
304 true, /* is_heap */ | |
305 cms->reserved().byte_size(), | |
306 true /* support_usage_threshold */); | |
307 break; | |
308 } | |
309 #endif // SERIALGC | |
310 | |
311 default: | |
312 assert(false, "should not reach here"); | |
313 // no memory pool added for others | |
314 break; | |
315 } | |
316 | |
317 assert(major_mgr != NULL, "Should have at least one manager"); | |
318 // Link managers and the memory pools together | |
319 for (int i = index; i < _pools_list->length(); i++) { | |
320 MemoryPool* pool = _pools_list->at(i); | |
321 major_mgr->add_pool(pool); | |
322 if (minor_mgr != NULL) { | |
323 minor_mgr->add_pool(pool); | |
324 } | |
325 } | |
326 } | |
327 | |
328 | |
329 #ifndef SERIALGC | |
330 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) { | |
331 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); | |
332 | |
333 // Add a memory pool for each space and young gen doesn't | |
334 // support low memory detection as it is expected to get filled up. | |
335 EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen, | |
336 gen->eden_space(), | |
337 "PS Eden Space", | |
338 MemoryPool::Heap, | |
339 false /* support_usage_threshold */); | |
340 | |
341 SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(gen, | |
342 "PS Survivor Space", | |
343 MemoryPool::Heap, | |
344 false /* support_usage_threshold */); | |
345 | |
346 major_mgr->add_pool(eden); | |
347 major_mgr->add_pool(survivor); | |
348 minor_mgr->add_pool(eden); | |
349 minor_mgr->add_pool(survivor); | |
350 _pools_list->append(eden); | |
351 _pools_list->append(survivor); | |
352 } | |
353 | |
354 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, MemoryManager* mgr) { | |
355 PSGenerationPool* old_gen = new PSGenerationPool(gen, | |
356 "PS Old Gen", | |
357 MemoryPool::Heap, | |
358 true /* support_usage_threshold */); | |
359 mgr->add_pool(old_gen); | |
360 _pools_list->append(old_gen); | |
361 } | |
362 | |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
363 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
364 MemoryManager* major_mgr, |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
365 MemoryManager* minor_mgr) { |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
366 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers"); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
367 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
368 G1EdenPool* eden = new G1EdenPool(g1h); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
369 G1SurvivorPool* survivor = new G1SurvivorPool(g1h); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
370 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
371 major_mgr->add_pool(eden); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
372 major_mgr->add_pool(survivor); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
373 minor_mgr->add_pool(eden); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
374 minor_mgr->add_pool(survivor); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
375 _pools_list->append(eden); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
376 _pools_list->append(survivor); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
377 } |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
378 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
379 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h, |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
380 MemoryManager* mgr) { |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
381 assert(mgr != NULL, "should have one manager"); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
382 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
383 G1OldGenPool* old_gen = new G1OldGenPool(g1h); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
384 mgr->add_pool(old_gen); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
385 _pools_list->append(old_gen); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
342
diff
changeset
|
386 } |
0 | 387 #endif // SERIALGC |
388 | |
389 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) { | |
390 _code_heap_pool = new CodeHeapPool(heap, | |
391 "Code Cache", | |
392 true /* support_usage_threshold */); | |
393 MemoryManager* mgr = MemoryManager::get_code_cache_memory_manager(); | |
394 mgr->add_pool(_code_heap_pool); | |
395 | |
396 _pools_list->append(_code_heap_pool); | |
397 _managers_list->append(mgr); | |
398 } | |
399 | |
400 MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) { | |
401 for (int i = 0; i < _managers_list->length(); i++) { | |
402 MemoryManager* mgr = _managers_list->at(i); | |
403 if (mgr->is_manager(mh)) { | |
404 return mgr; | |
405 } | |
406 } | |
407 return NULL; | |
408 } | |
409 | |
410 MemoryPool* MemoryService::get_memory_pool(instanceHandle ph) { | |
411 for (int i = 0; i < _pools_list->length(); i++) { | |
412 MemoryPool* pool = _pools_list->at(i); | |
413 if (pool->is_pool(ph)) { | |
414 return pool; | |
415 } | |
416 } | |
417 return NULL; | |
418 } | |
419 | |
420 void MemoryService::track_memory_usage() { | |
421 // Track the peak memory usage | |
422 for (int i = 0; i < _pools_list->length(); i++) { | |
423 MemoryPool* pool = _pools_list->at(i); | |
424 pool->record_peak_memory_usage(); | |
425 } | |
426 | |
427 // Detect low memory | |
428 LowMemoryDetector::detect_low_memory(); | |
429 } | |
430 | |
431 void MemoryService::track_memory_pool_usage(MemoryPool* pool) { | |
432 // Track the peak memory usage | |
433 pool->record_peak_memory_usage(); | |
434 | |
435 // Detect low memory | |
436 if (LowMemoryDetector::is_enabled(pool)) { | |
437 LowMemoryDetector::detect_low_memory(pool); | |
438 } | |
439 } | |
440 | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
441 void MemoryService::gc_begin(bool fullGC, bool recordGCBeginTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
442 bool recordAccumulatedGCTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
443 bool recordPreGCUsage, bool recordPeakUsage) { |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
444 |
0 | 445 GCMemoryManager* mgr; |
446 if (fullGC) { | |
447 mgr = _major_gc_manager; | |
448 } else { | |
449 mgr = _minor_gc_manager; | |
450 } | |
451 assert(mgr->is_gc_memory_manager(), "Sanity check"); | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
452 mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime); |
0 | 453 |
454 // Track the peak memory usage when GC begins | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
455 if (recordPeakUsage) { |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
456 for (int i = 0; i < _pools_list->length(); i++) { |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
457 MemoryPool* pool = _pools_list->at(i); |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
458 pool->record_peak_memory_usage(); |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
459 } |
0 | 460 } |
461 } | |
462 | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
463 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
464 bool recordAccumulatedGCTime, |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
465 bool recordGCEndTime, bool countCollection, |
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
466 GCCause::Cause cause) { |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
467 |
0 | 468 GCMemoryManager* mgr; |
469 if (fullGC) { | |
470 mgr = (GCMemoryManager*) _major_gc_manager; | |
471 } else { | |
472 mgr = (GCMemoryManager*) _minor_gc_manager; | |
473 } | |
474 assert(mgr->is_gc_memory_manager(), "Sanity check"); | |
475 | |
476 // register the GC end statistics and memory usage | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
477 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
478 countCollection, cause); |
0 | 479 } |
480 | |
481 void MemoryService::oops_do(OopClosure* f) { | |
482 int i; | |
483 | |
484 for (i = 0; i < _pools_list->length(); i++) { | |
485 MemoryPool* pool = _pools_list->at(i); | |
486 pool->oops_do(f); | |
487 } | |
488 for (i = 0; i < _managers_list->length(); i++) { | |
489 MemoryManager* mgr = _managers_list->at(i); | |
490 mgr->oops_do(f); | |
491 } | |
492 } | |
493 | |
494 bool MemoryService::set_verbose(bool verbose) { | |
495 MutexLocker m(Management_lock); | |
496 // verbose will be set to the previous value | |
497 bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, MANAGEMENT); | |
498 assert(succeed, "Setting PrintGC flag fails"); | |
499 ClassLoadingService::reset_trace_class_unloading(); | |
500 | |
501 return verbose; | |
502 } | |
503 | |
504 Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
505 Klass* k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH); |
0 | 506 instanceKlassHandle ik(THREAD, k); |
507 | |
508 instanceHandle obj = ik->allocate_instance_handle(CHECK_NH); | |
509 | |
510 JavaValue result(T_VOID); | |
511 JavaCallArguments args(10); | |
512 args.push_oop(obj); // receiver | |
513 args.push_long(usage.init_size_as_jlong()); // Argument 1 | |
514 args.push_long(usage.used_as_jlong()); // Argument 2 | |
515 args.push_long(usage.committed_as_jlong()); // Argument 3 | |
516 args.push_long(usage.max_size_as_jlong()); // Argument 4 | |
517 | |
518 JavaCalls::call_special(&result, | |
519 ik, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
520 vmSymbols::object_initializer_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
521 vmSymbols::long_long_long_long_void_signature(), |
0 | 522 &args, |
523 CHECK_NH); | |
524 return obj; | |
525 } | |
526 // | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
527 // GC manager type depends on the type of Generation. Depending on the space |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
528 // availablity and vm options the gc uses major gc manager or minor gc |
0 | 529 // manager or both. The type of gc manager depends on the generation kind. |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
530 // For DefNew, ParNew and ASParNew generation doing scavenge gc uses minor |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
531 // gc manager (so _fullGC is set to false ) and for other generation kinds |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
532 // doing mark-sweep-compact uses major gc manager (so _fullGC is set |
0 | 533 // to true). |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
534 TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) { |
0 | 535 switch (kind) { |
536 case Generation::DefNew: | |
537 #ifndef SERIALGC | |
538 case Generation::ParNew: | |
539 case Generation::ASParNew: | |
540 #endif // SERIALGC | |
541 _fullGC=false; | |
542 break; | |
543 case Generation::MarkSweepCompact: | |
544 #ifndef SERIALGC | |
545 case Generation::ConcurrentMarkSweep: | |
546 case Generation::ASConcurrentMarkSweep: | |
547 #endif // SERIALGC | |
548 _fullGC=true; | |
549 break; | |
550 default: | |
551 assert(false, "Unrecognized gc generation kind."); | |
552 } | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
553 // this has to be called in a stop the world pause and represent |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
554 // an entire gc pause, start to finish: |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
555 initialize(_fullGC, cause,true, true, true, true, true, true, true); |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
556 } |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
557 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC, |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
558 GCCause::Cause cause, |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
559 bool recordGCBeginTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
560 bool recordPreGCUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
561 bool recordPeakUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
562 bool recordPostGCUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
563 bool recordAccumulatedGCTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
564 bool recordGCEndTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
565 bool countCollection) { |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
566 initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
567 recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
568 countCollection); |
0 | 569 } |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
570 |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
571 // for a subclass to create then initialize an instance before invoking |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
572 // the MemoryService |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
573 void TraceMemoryManagerStats::initialize(bool fullGC, |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
574 GCCause::Cause cause, |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
575 bool recordGCBeginTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
576 bool recordPreGCUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
577 bool recordPeakUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
578 bool recordPostGCUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
579 bool recordAccumulatedGCTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
580 bool recordGCEndTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
581 bool countCollection) { |
0 | 582 _fullGC = fullGC; |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
583 _recordGCBeginTime = recordGCBeginTime; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
584 _recordPreGCUsage = recordPreGCUsage; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
585 _recordPeakUsage = recordPeakUsage; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
586 _recordPostGCUsage = recordPostGCUsage; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
587 _recordAccumulatedGCTime = recordAccumulatedGCTime; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
588 _recordGCEndTime = recordGCEndTime; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
589 _countCollection = countCollection; |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
590 _cause = cause; |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
591 |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
592 MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
593 _recordPreGCUsage, _recordPeakUsage); |
0 | 594 } |
595 | |
596 TraceMemoryManagerStats::~TraceMemoryManagerStats() { | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
597 MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime, |
3356
78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
2426
diff
changeset
|
598 _recordGCEndTime, _countCollection, _cause); |
0 | 599 } |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
600 |