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