comparison src/share/vm/services/memoryPool.cpp @ 8825:dbd5837b342f

8000754: NPG: Implement a MemoryPool MXBean for Metaspace Reviewed-by: jmasa, stefank
author ehelin
date Fri, 22 Mar 2013 16:10:01 +0100
parents db9981fd3124
children 42e370795a39
comparison
equal deleted inserted replaced
8824:7f16d1812865 8825:dbd5837b342f
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "classfile/systemDictionary.hpp" 26 #include "classfile/systemDictionary.hpp"
27 #include "classfile/vmSymbols.hpp" 27 #include "classfile/vmSymbols.hpp"
28 #include "oops/oop.inline.hpp" 28 #include "oops/oop.inline.hpp"
29 #include "runtime/globals.hpp"
29 #include "runtime/handles.inline.hpp" 30 #include "runtime/handles.inline.hpp"
30 #include "runtime/javaCalls.hpp" 31 #include "runtime/javaCalls.hpp"
32 #include "runtime/os.hpp"
31 #include "services/lowMemoryDetector.hpp" 33 #include "services/lowMemoryDetector.hpp"
32 #include "services/management.hpp" 34 #include "services/management.hpp"
33 #include "services/memoryManager.hpp" 35 #include "services/memoryManager.hpp"
34 #include "services/memoryPool.hpp" 36 #include "services/memoryPool.hpp"
37 #include "utilities/globalDefinitions.hpp"
35 #include "utilities/macros.hpp" 38 #include "utilities/macros.hpp"
36 39
37 MemoryPool::MemoryPool(const char* name, 40 MemoryPool::MemoryPool(const char* name,
38 PoolType type, 41 PoolType type,
39 size_t init_size, 42 size_t init_size,
254 size_t committed = _codeHeap->capacity(); 257 size_t committed = _codeHeap->capacity();
255 size_t maxSize = (available_for_allocation() ? max_size() : 0); 258 size_t maxSize = (available_for_allocation() ? max_size() : 0);
256 259
257 return MemoryUsage(initial_size(), used, committed, maxSize); 260 return MemoryUsage(initial_size(), used, committed, maxSize);
258 } 261 }
262
263 MetaspacePoolBase::MetaspacePoolBase(const char *name,
264 Metaspace::MetadataType md_type,
265 size_t max_size) :
266 _md_type(md_type),
267 MemoryPool(name, NonHeap, MetaspaceAux::capacity_in_bytes(_md_type), max_size,
268 true, false) { }
269
270 size_t MetaspacePoolBase::used_in_bytes() {
271 return MetaspaceAux::used_in_bytes(_md_type);
272 }
273
274 MemoryUsage MetaspacePoolBase::get_memory_usage() {
275 size_t used = MetaspaceAux::used_in_bytes(_md_type);
276 size_t committed = align_size_down_(MetaspaceAux::capacity_in_bytes(_md_type), os::vm_page_size());
277 return MemoryUsage(initial_size(), used, committed, max_size());
278 }
279
280 ClassMetaspacePool::ClassMetaspacePool() :
281 MetaspacePoolBase("Class Metaspace", Metaspace::ClassType, calculate_max_size()) { }
282
283 size_t ClassMetaspacePool::calculate_max_size() {
284 return UseCompressedKlassPointers ? ClassMetaspaceSize : _undefined_max_size;
285 }
286
287 MetaspacePool::MetaspacePool() :
288 MetaspacePoolBase("Metaspace", Metaspace::NonClassType, calculate_max_size()) { }
289
290 size_t MetaspacePool::calculate_max_size() {
291 return FLAG_IS_CMDLINE(MaxMetaspaceSize) ? MaxMetaspaceSize : _undefined_max_size;
292 }