// Returns an instanceOop of a MemoryPool object. // It creates a MemoryPool instance when the first time // this function is called.
instanceOop MemoryPool::get_memory_pool_instance(TRAPS) { // Must do an acquire so as to force ordering of subsequent // loads from anything _memory_pool_obj points to or implies.
oop pool_obj = Atomic::load_acquire(&_memory_pool_obj).resolve(); if (pool_obj == NULL) { // It's ok for more than one thread to execute the code up to the locked region. // Extra pool instances will just be gc'ed.
InstanceKlass* ik = Management::sun_management_ManagementFactoryHelper_klass(CHECK_NULL);
instanceOop p = (instanceOop) result.get_oop();
instanceHandle pool(THREAD, p);
{ // Get lock since another thread may have create the instance
MutexLocker ml(THREAD, Management_lock);
// Check if another thread has created the pool. We reload // _memory_pool_obj here because some other thread may have // initialized it while we were executing the code before the lock.
pool_obj = Atomic::load(&_memory_pool_obj).resolve(); if (pool_obj != NULL) { return (instanceOop)pool_obj;
}
// Get the address of the object we created via call_special.
pool_obj = pool();
// Use store barrier to make sure the memory accesses associated // with creating the pool are visible before publishing its address. // The unlock will publish the store to _memory_pool_obj because // it does a release first.
Atomic::release_store(&_memory_pool_obj, OopHandle(Universe::vm_global(), pool_obj));
}
}
void MemoryPool::record_peak_memory_usage() { // Caller in JDK is responsible for synchronization - // acquire the lock for this memory pool before calling VM
MemoryUsage usage = get_memory_usage();
size_t peak_used = get_max_value(usage.used(), _peak_usage.used());
size_t peak_committed = get_max_value(usage.committed(), _peak_usage.committed());
size_t peak_max_size = get_max_value(usage.max_size(), _peak_usage.max_size());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.