annotate src/share/vm/services/memoryService.cpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents a61af66fc99e
children 37f87013dfd8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_memoryService.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 GrowableArray<MemoryPool*>* MemoryService::_pools_list =
a61af66fc99e Initial load
duke
parents:
diff changeset
29 new (ResourceObj::C_HEAP) GrowableArray<MemoryPool*>(init_pools_list_size, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
30 GrowableArray<MemoryManager*>* MemoryService::_managers_list =
a61af66fc99e Initial load
duke
parents:
diff changeset
31 new (ResourceObj::C_HEAP) GrowableArray<MemoryManager*>(init_managers_list_size, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 GCMemoryManager* MemoryService::_minor_gc_manager = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 GCMemoryManager* MemoryService::_major_gc_manager = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 MemoryPool* MemoryService::_code_heap_pool = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class GcThreadCountClosure: public ThreadClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 int _count;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 GcThreadCountClosure() : _count(0) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
42 void do_thread(Thread* thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 int count() { return _count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
44 };
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 void GcThreadCountClosure::do_thread(Thread* thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void MemoryService::set_universe_heap(CollectedHeap* heap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 CollectedHeap::Name kind = heap->kind();
a61af66fc99e Initial load
duke
parents:
diff changeset
52 switch (kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 case CollectedHeap::GenCollectedHeap : {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 add_gen_collected_heap_info(GenCollectedHeap::heap());
a61af66fc99e Initial load
duke
parents:
diff changeset
55 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
58 case CollectedHeap::ParallelScavengeHeap : {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap());
a61af66fc99e Initial load
duke
parents:
diff changeset
60 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
63 default: {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 guarantee(false, "Not recognized kind of heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // set the GC thread count
a61af66fc99e Initial load
duke
parents:
diff changeset
69 GcThreadCountClosure gctcc;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 heap->gc_threads_do(&gctcc);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int count = gctcc.count();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (count > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _minor_gc_manager->set_num_gc_threads(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _major_gc_manager->set_num_gc_threads(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // All memory pools and memory managers are initialized.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _minor_gc_manager->initialize_gc_stat_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _major_gc_manager->initialize_gc_stat_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Add memory pools for GenCollectedHeap
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // This function currently only supports two generations collected heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // The collector for GenCollectedHeap will have two memory managers.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 CollectorPolicy* policy = heap->collector_policy();
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 assert(policy->is_two_generation_policy(), "Only support two generations");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 guarantee(heap->n_gens() == 2, "Only support two-generation heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 TwoGenerationCollectorPolicy* two_gen_policy = policy->as_two_generation_policy();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (two_gen_policy != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 GenerationSpec** specs = two_gen_policy->generations();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Generation::Name kind = specs[0]->name();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 switch (kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 case Generation::DefNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _minor_gc_manager = MemoryManager::get_copy_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
101 case Generation::ParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
102 case Generation::ASParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _minor_gc_manager = MemoryManager::get_parnew_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
104 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
106 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
107 guarantee(false, "Unrecognized generation spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (policy->is_mark_sweep_policy()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _major_gc_manager = MemoryManager::get_msc_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
113 } else if (policy->is_concurrent_mark_sweep_policy()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _major_gc_manager = MemoryManager::get_cms_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
116 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 guarantee(false, "Unknown two-gen policy");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 guarantee(false, "Non two-gen policy");
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _managers_list->append(_minor_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 _managers_list->append(_major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 add_generation_memory_pool(heap->get_gen(minor), _major_gc_manager, _minor_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 add_generation_memory_pool(heap->get_gen(major), _major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 PermGen::Name name = policy->permanent_generation()->name();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 switch (name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 case PermGen::MarkSweepCompact: {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 CompactingPermGenGen* perm_gen = (CompactingPermGenGen*) heap->perm_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 add_compact_perm_gen_memory_pool(perm_gen, _major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
136 case PermGen::ConcurrentMarkSweep: {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 CMSPermGenGen* cms_gen = (CMSPermGenGen*) heap->perm_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 add_cms_perm_gen_memory_pool(cms_gen, _major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
142 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
143 guarantee(false, "Unrecognized perm generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Add memory pools for ParallelScavengeHeap
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // This function currently only supports two generations collected heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // The collector for ParallelScavengeHeap will have two memory managers.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
156 _managers_list->append(_minor_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 _managers_list->append(_major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 add_psPerm_memory_pool(heap->perm_gen(), _major_gc_manager);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 MemoryPool* MemoryService::add_gen(Generation* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
166 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
167 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
168 bool support_usage_threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 _pools_list->append(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return (MemoryPool*) pool;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 MemoryPool* MemoryService::add_space(ContiguousSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
177 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
178 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
179 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
180 bool support_usage_threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 _pools_list->append(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 return (MemoryPool*) pool;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
189 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
190 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
191 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
192 bool support_usage_threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(gen, name, type, max_size, support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 _pools_list->append(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return (MemoryPool*) pool;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
201 MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
202 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
203 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
204 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 bool support_usage_threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 _pools_list->append(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return (MemoryPool*) pool;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Add memory pool(s) for one generation
a61af66fc99e Initial load
duke
parents:
diff changeset
214 void MemoryService::add_generation_memory_pool(Generation* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
215 MemoryManager* major_mgr,
a61af66fc99e Initial load
duke
parents:
diff changeset
216 MemoryManager* minor_mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 Generation::Name kind = gen->kind();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 int index = _pools_list->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 switch (kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 case Generation::DefNew: {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 DefNewGeneration* young_gen = (DefNewGeneration*) gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Add a memory pool for each space and young gen doesn't
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // support low memory detection as it is expected to get filled up.
a61af66fc99e Initial load
duke
parents:
diff changeset
226 MemoryPool* eden = add_space(young_gen->eden(),
a61af66fc99e Initial load
duke
parents:
diff changeset
227 "Eden Space",
a61af66fc99e Initial load
duke
parents:
diff changeset
228 true, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
229 young_gen->max_eden_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
230 false /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 MemoryPool* survivor = add_survivor_spaces(young_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
232 "Survivor Space",
a61af66fc99e Initial load
duke
parents:
diff changeset
233 true, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
234 young_gen->max_survivor_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
235 false /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
240 case Generation::ParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
241 case Generation::ASParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
242 {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Add a memory pool for each space and young gen doesn't
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // support low memory detection as it is expected to get filled up.
a61af66fc99e Initial load
duke
parents:
diff changeset
246 ParNewGeneration* parnew_gen = (ParNewGeneration*) gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 MemoryPool* eden = add_space(parnew_gen->eden(),
a61af66fc99e Initial load
duke
parents:
diff changeset
248 "Par Eden Space",
a61af66fc99e Initial load
duke
parents:
diff changeset
249 true /* is_heap */,
a61af66fc99e Initial load
duke
parents:
diff changeset
250 parnew_gen->max_eden_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
251 false /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 MemoryPool* survivor = add_survivor_spaces(parnew_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
253 "Par Survivor Space",
a61af66fc99e Initial load
duke
parents:
diff changeset
254 true, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
255 parnew_gen->max_survivor_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
256 false /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 case Generation::MarkSweepCompact: {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 add_gen(gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
265 "Tenured Gen",
a61af66fc99e Initial load
duke
parents:
diff changeset
266 true, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
267 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
272 case Generation::ConcurrentMarkSweep:
a61af66fc99e Initial load
duke
parents:
diff changeset
273 case Generation::ASConcurrentMarkSweep:
a61af66fc99e Initial load
duke
parents:
diff changeset
274 {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
a61af66fc99e Initial load
duke
parents:
diff changeset
276 ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 MemoryPool* pool = add_cms_space(cms->cmsSpace(),
a61af66fc99e Initial load
duke
parents:
diff changeset
278 "CMS Old Gen",
a61af66fc99e Initial load
duke
parents:
diff changeset
279 true, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
280 cms->reserved().byte_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
281 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
287 assert(false, "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // no memory pool added for others
a61af66fc99e Initial load
duke
parents:
diff changeset
289 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 assert(major_mgr != NULL, "Should have at least one manager");
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // Link managers and the memory pools together
a61af66fc99e Initial load
duke
parents:
diff changeset
294 for (int i = index; i < _pools_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 MemoryPool* pool = _pools_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 major_mgr->add_pool(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (minor_mgr != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 minor_mgr->add_pool(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 void MemoryService::add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
304 MemoryManager* mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 PermanentGenerationSpec* spec = perm_gen->spec();
a61af66fc99e Initial load
duke
parents:
diff changeset
306 size_t max_size = spec->max_size() - spec->read_only_size() - spec->read_write_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 MemoryPool* pool = add_space(perm_gen->unshared_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
308 "Perm Gen",
a61af66fc99e Initial load
duke
parents:
diff changeset
309 false, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
310 max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
311 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 mgr->add_pool(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 if (UseSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 pool = add_space(perm_gen->ro_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
315 "Perm Gen [shared-ro]",
a61af66fc99e Initial load
duke
parents:
diff changeset
316 false, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
317 spec->read_only_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
318 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 mgr->add_pool(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 pool = add_space(perm_gen->rw_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
322 "Perm Gen [shared-rw]",
a61af66fc99e Initial load
duke
parents:
diff changeset
323 false, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
324 spec->read_write_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
325 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 mgr->add_pool(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
331 void MemoryService::add_cms_perm_gen_memory_pool(CMSPermGenGen* cms_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
332 MemoryManager* mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 MemoryPool* pool = add_cms_space(cms_gen->cmsSpace(),
a61af66fc99e Initial load
duke
parents:
diff changeset
335 "CMS Perm Gen",
a61af66fc99e Initial load
duke
parents:
diff changeset
336 false, /* is_heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
337 cms_gen->reserved().byte_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
338 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 mgr->add_pool(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // Add a memory pool for each space and young gen doesn't
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // support low memory detection as it is expected to get filled up.
a61af66fc99e Initial load
duke
parents:
diff changeset
347 EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
348 gen->eden_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
349 "PS Eden Space",
a61af66fc99e Initial load
duke
parents:
diff changeset
350 MemoryPool::Heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
351 false /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
354 "PS Survivor Space",
a61af66fc99e Initial load
duke
parents:
diff changeset
355 MemoryPool::Heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
356 false /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 major_mgr->add_pool(eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
359 major_mgr->add_pool(survivor);
a61af66fc99e Initial load
duke
parents:
diff changeset
360 minor_mgr->add_pool(eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 minor_mgr->add_pool(survivor);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 _pools_list->append(eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 _pools_list->append(survivor);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, MemoryManager* mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 PSGenerationPool* old_gen = new PSGenerationPool(gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
368 "PS Old Gen",
a61af66fc99e Initial load
duke
parents:
diff changeset
369 MemoryPool::Heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
370 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 mgr->add_pool(old_gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 _pools_list->append(old_gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 void MemoryService::add_psPerm_memory_pool(PSPermGen* gen, MemoryManager* mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 PSGenerationPool* perm_gen = new PSGenerationPool(gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
377 "PS Perm Gen",
a61af66fc99e Initial load
duke
parents:
diff changeset
378 MemoryPool::NonHeap,
a61af66fc99e Initial load
duke
parents:
diff changeset
379 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
380 mgr->add_pool(perm_gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
381 _pools_list->append(perm_gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
383 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 _code_heap_pool = new CodeHeapPool(heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
387 "Code Cache",
a61af66fc99e Initial load
duke
parents:
diff changeset
388 true /* support_usage_threshold */);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 MemoryManager* mgr = MemoryManager::get_code_cache_memory_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
390 mgr->add_pool(_code_heap_pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 _pools_list->append(_code_heap_pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
393 _managers_list->append(mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 for (int i = 0; i < _managers_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 MemoryManager* mgr = _managers_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 if (mgr->is_manager(mh)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 return mgr;
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 MemoryPool* MemoryService::get_memory_pool(instanceHandle ph) {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 for (int i = 0; i < _pools_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 MemoryPool* pool = _pools_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 if (pool->is_pool(ph)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 return pool;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 void MemoryService::track_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 // Track the peak memory usage
a61af66fc99e Initial load
duke
parents:
diff changeset
418 for (int i = 0; i < _pools_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 MemoryPool* pool = _pools_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
420 pool->record_peak_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // Detect low memory
a61af66fc99e Initial load
duke
parents:
diff changeset
424 LowMemoryDetector::detect_low_memory();
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 void MemoryService::track_memory_pool_usage(MemoryPool* pool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Track the peak memory usage
a61af66fc99e Initial load
duke
parents:
diff changeset
429 pool->record_peak_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // Detect low memory
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (LowMemoryDetector::is_enabled(pool)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 LowMemoryDetector::detect_low_memory(pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 void MemoryService::gc_begin(bool fullGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 GCMemoryManager* mgr;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 if (fullGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
440 mgr = _major_gc_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 mgr = _minor_gc_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
444 assert(mgr->is_gc_memory_manager(), "Sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
445 mgr->gc_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // Track the peak memory usage when GC begins
a61af66fc99e Initial load
duke
parents:
diff changeset
448 for (int i = 0; i < _pools_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 MemoryPool* pool = _pools_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 pool->record_peak_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 void MemoryService::gc_end(bool fullGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 GCMemoryManager* mgr;
a61af66fc99e Initial load
duke
parents:
diff changeset
456 if (fullGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
457 mgr = (GCMemoryManager*) _major_gc_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
458 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 mgr = (GCMemoryManager*) _minor_gc_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461 assert(mgr->is_gc_memory_manager(), "Sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // register the GC end statistics and memory usage
a61af66fc99e Initial load
duke
parents:
diff changeset
464 mgr->gc_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
466
a61af66fc99e Initial load
duke
parents:
diff changeset
467 void MemoryService::oops_do(OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
468 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 for (i = 0; i < _pools_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
471 MemoryPool* pool = _pools_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
472 pool->oops_do(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
474 for (i = 0; i < _managers_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 MemoryManager* mgr = _managers_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
476 mgr->oops_do(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 }
a61af66fc99e Initial load
duke
parents:
diff changeset
479
a61af66fc99e Initial load
duke
parents:
diff changeset
480 bool MemoryService::set_verbose(bool verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
481 MutexLocker m(Management_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // verbose will be set to the previous value
a61af66fc99e Initial load
duke
parents:
diff changeset
483 bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, MANAGEMENT);
a61af66fc99e Initial load
duke
parents:
diff changeset
484 assert(succeed, "Setting PrintGC flag fails");
a61af66fc99e Initial load
duke
parents:
diff changeset
485 ClassLoadingService::reset_trace_class_unloading();
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 return verbose;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 klassOop k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
a61af66fc99e Initial load
duke
parents:
diff changeset
492 instanceKlassHandle ik(THREAD, k);
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 JavaValue result(T_VOID);
a61af66fc99e Initial load
duke
parents:
diff changeset
497 JavaCallArguments args(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 args.push_oop(obj); // receiver
a61af66fc99e Initial load
duke
parents:
diff changeset
499 args.push_long(usage.init_size_as_jlong()); // Argument 1
a61af66fc99e Initial load
duke
parents:
diff changeset
500 args.push_long(usage.used_as_jlong()); // Argument 2
a61af66fc99e Initial load
duke
parents:
diff changeset
501 args.push_long(usage.committed_as_jlong()); // Argument 3
a61af66fc99e Initial load
duke
parents:
diff changeset
502 args.push_long(usage.max_size_as_jlong()); // Argument 4
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 JavaCalls::call_special(&result,
a61af66fc99e Initial load
duke
parents:
diff changeset
505 ik,
a61af66fc99e Initial load
duke
parents:
diff changeset
506 vmSymbolHandles::object_initializer_name(),
a61af66fc99e Initial load
duke
parents:
diff changeset
507 vmSymbolHandles::long_long_long_long_void_signature(),
a61af66fc99e Initial load
duke
parents:
diff changeset
508 &args,
a61af66fc99e Initial load
duke
parents:
diff changeset
509 CHECK_NH);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 return obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512 //
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // GC manager type depends on the type of Generation. Depending the space
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // availablity and vm option the gc uses major gc manager or minor gc
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // manager or both. The type of gc manager depends on the generation kind.
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // For DefNew, ParNew and ASParNew generation doing scavange gc uses minor
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // gc manager (so _fullGC is set to false ) and for other generation kind
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // DOing mark-sweep-compact uses major gc manager (so _fullGC is set
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // to true).
a61af66fc99e Initial load
duke
parents:
diff changeset
520 TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
521 switch (kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
522 case Generation::DefNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
523 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
524 case Generation::ParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
525 case Generation::ASParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
526 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
527 _fullGC=false;
a61af66fc99e Initial load
duke
parents:
diff changeset
528 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
529 case Generation::MarkSweepCompact:
a61af66fc99e Initial load
duke
parents:
diff changeset
530 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
531 case Generation::ConcurrentMarkSweep:
a61af66fc99e Initial load
duke
parents:
diff changeset
532 case Generation::ASConcurrentMarkSweep:
a61af66fc99e Initial load
duke
parents:
diff changeset
533 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
534 _fullGC=true;
a61af66fc99e Initial load
duke
parents:
diff changeset
535 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
537 assert(false, "Unrecognized gc generation kind.");
a61af66fc99e Initial load
duke
parents:
diff changeset
538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
539 MemoryService::gc_begin(_fullGC);
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 _fullGC = fullGC;
a61af66fc99e Initial load
duke
parents:
diff changeset
543 MemoryService::gc_begin(_fullGC);
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
a61af66fc99e Initial load
duke
parents:
diff changeset
547 MemoryService::gc_end(_fullGC);
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }