annotate src/share/vm/services/memoryPool.cpp @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents a61af66fc99e
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
diff changeset
21 * questions.
0
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/_memoryPool.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 MemoryPool::MemoryPool(const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
29 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
30 size_t init_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
31 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
32 bool support_usage_threshold,
a61af66fc99e Initial load
duke
parents:
diff changeset
33 bool support_gc_threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 _name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 _initial_size = init_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 _max_size = max_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _memory_pool_obj = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 _available_for_allocation = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _num_managers = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _type = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // initialize the max and init size of collection usage
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _usage_sensor = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 _gc_usage_sensor = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // usage threshold supports both high and low threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
48 _usage_threshold = new ThresholdSupport(support_usage_threshold, support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // gc usage threshold supports only high threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _gc_usage_threshold = new ThresholdSupport(support_gc_threshold, support_gc_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 void MemoryPool::add_manager(MemoryManager* mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 assert(_num_managers < MemoryPool::max_num_managers, "_num_managers exceeds the max");
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (_num_managers < MemoryPool::max_num_managers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _managers[_num_managers] = mgr;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _num_managers++;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Returns an instanceHandle of a MemoryPool object.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // It creates a MemoryPool instance when the first time
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // this function is called.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 instanceOop MemoryPool::get_memory_pool_instance(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Must do an acquire so as to force ordering of subsequent
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // loads from anything _memory_pool_obj points to or implies.
a61af66fc99e Initial load
duke
parents:
diff changeset
68 instanceOop pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (pool_obj == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // It's ok for more than one thread to execute the code up to the locked region.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Extra pool instances will just be gc'ed.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 klassOop k = Management::sun_management_ManagementFactory_klass(CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 instanceKlassHandle ik(THREAD, k);
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 Handle pool_name = java_lang_String::create_from_str(_name, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 jlong usage_threshold_value = (_usage_threshold->is_high_threshold_supported() ? 0 : -1L);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 jlong gc_usage_threshold_value = (_gc_usage_threshold->is_high_threshold_supported() ? 0 : -1L);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 JavaValue result(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 JavaCallArguments args;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 args.push_oop(pool_name); // Argument 1
a61af66fc99e Initial load
duke
parents:
diff changeset
82 args.push_int((int) is_heap()); // Argument 2
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 symbolHandle method_name = vmSymbolHandles::createMemoryPool_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 symbolHandle signature = vmSymbolHandles::createMemoryPool_signature();
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 args.push_long(usage_threshold_value); // Argument 3
a61af66fc99e Initial load
duke
parents:
diff changeset
88 args.push_long(gc_usage_threshold_value); // Argument 4
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 JavaCalls::call_static(&result,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 ik,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 method_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 signature,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 &args,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 instanceOop p = (instanceOop) result.get_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 instanceHandle pool(THREAD, p);
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Get lock since another thread may have create the instance
a61af66fc99e Initial load
duke
parents:
diff changeset
102 MutexLocker ml(Management_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Check if another thread has created the pool. We reload
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // _memory_pool_obj here because some other thread may have
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // initialized it while we were executing the code before the lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 //
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // The lock has done an acquire, so the load can't float above it,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // but we need to do a load_acquire as above.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (pool_obj != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return pool_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Get the address of the object we created via call_special.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 pool_obj = pool();
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Use store barrier to make sure the memory accesses associated
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // with creating the pool are visible before publishing its address.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // The unlock will publish the store to _memory_pool_obj because
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // it does a release first.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 OrderAccess::release_store_ptr(&_memory_pool_obj, pool_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return pool_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 inline static size_t get_max_value(size_t val1, size_t val2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return (val1 > val2 ? val1 : val2);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 void MemoryPool::record_peak_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Caller in JDK is responsible for synchronization -
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // acquire the lock for this memory pool before calling VM
a61af66fc99e Initial load
duke
parents:
diff changeset
136 MemoryUsage usage = get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 size_t peak_used = get_max_value(usage.used(), _peak_usage.used());
a61af66fc99e Initial load
duke
parents:
diff changeset
138 size_t peak_committed = get_max_value(usage.committed(), _peak_usage.committed());
a61af66fc99e Initial load
duke
parents:
diff changeset
139 size_t peak_max_size = get_max_value(usage.max_size(), _peak_usage.max_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 _peak_usage = MemoryUsage(initial_size(), peak_used, peak_committed, peak_max_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 static void set_sensor_obj_at(SensorInfo** sensor_ptr, instanceHandle sh) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(*sensor_ptr == NULL, "Should be called only once");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 SensorInfo* sensor = new SensorInfo();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 sensor->set_sensor(sh());
a61af66fc99e Initial load
duke
parents:
diff changeset
148 *sensor_ptr = sensor;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void MemoryPool::set_usage_sensor_obj(instanceHandle sh) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 set_sensor_obj_at(&_usage_sensor, sh);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 void MemoryPool::set_gc_usage_sensor_obj(instanceHandle sh) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 set_sensor_obj_at(&_gc_usage_sensor, sh);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void MemoryPool::oops_do(OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 f->do_oop((oop*) &_memory_pool_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (_usage_sensor != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 _usage_sensor->oops_do(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 if (_gc_usage_sensor != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 _gc_usage_sensor->oops_do(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 ContiguousSpacePool::ContiguousSpacePool(ContiguousSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
170 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
171 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
172 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
173 bool support_usage_threshold) :
a61af66fc99e Initial load
duke
parents:
diff changeset
174 CollectedMemoryPool(name, type, space->capacity(), max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
175 support_usage_threshold), _space(space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 MemoryUsage ContiguousSpacePool::get_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 size_t maxSize = (available_for_allocation() ? max_size() : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 size_t used = used_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 size_t committed = _space->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return MemoryUsage(initial_size(), used, committed, maxSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 SurvivorContiguousSpacePool::SurvivorContiguousSpacePool(DefNewGeneration* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
187 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
188 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
189 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
190 bool support_usage_threshold) :
a61af66fc99e Initial load
duke
parents:
diff changeset
191 CollectedMemoryPool(name, type, gen->from()->capacity(), max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
192 support_usage_threshold), _gen(gen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 size_t maxSize = (available_for_allocation() ? max_size() : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 size_t used = used_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 size_t committed = committed_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return MemoryUsage(initial_size(), used, committed, maxSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
204 CompactibleFreeListSpacePool::CompactibleFreeListSpacePool(CompactibleFreeListSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
206 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
207 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 bool support_usage_threshold) :
a61af66fc99e Initial load
duke
parents:
diff changeset
209 CollectedMemoryPool(name, type, space->capacity(), max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
210 support_usage_threshold), _space(space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 size_t maxSize = (available_for_allocation() ? max_size() : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 size_t used = used_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 size_t committed = _space->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return MemoryUsage(initial_size(), used, committed, maxSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 GenerationPool::GenerationPool(Generation* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
223 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
224 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
225 bool support_usage_threshold) :
a61af66fc99e Initial load
duke
parents:
diff changeset
226 CollectedMemoryPool(name, type, gen->capacity(), gen->max_capacity(),
a61af66fc99e Initial load
duke
parents:
diff changeset
227 support_usage_threshold), _gen(gen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 MemoryUsage GenerationPool::get_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 size_t used = used_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
232 size_t committed = _gen->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 size_t maxSize = (available_for_allocation() ? max_size() : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return MemoryUsage(initial_size(), used, committed, maxSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 CodeHeapPool::CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_usage_threshold) :
a61af66fc99e Initial load
duke
parents:
diff changeset
239 MemoryPool(name, NonHeap, codeHeap->capacity(), codeHeap->max_capacity(),
a61af66fc99e Initial load
duke
parents:
diff changeset
240 support_usage_threshold, false), _codeHeap(codeHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 MemoryUsage CodeHeapPool::get_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 size_t used = used_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
245 size_t committed = _codeHeap->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 size_t maxSize = (available_for_allocation() ? max_size() : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return MemoryUsage(initial_size(), used, committed, maxSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }