duke@435: /* coleenp@4037: * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "classfile/systemDictionary.hpp" stefank@2314: #include "classfile/vmSymbols.hpp" stefank@2314: #include "oops/oop.inline.hpp" stefank@2314: #include "runtime/handles.inline.hpp" stefank@2314: #include "runtime/javaCalls.hpp" stefank@2314: #include "services/lowMemoryDetector.hpp" stefank@2314: #include "services/management.hpp" stefank@2314: #include "services/memoryManager.hpp" stefank@2314: #include "services/psMemoryPool.hpp" duke@435: duke@435: PSGenerationPool::PSGenerationPool(PSOldGen* gen, duke@435: const char* name, duke@435: PoolType type, duke@435: bool support_usage_threshold) : duke@435: CollectedMemoryPool(name, type, gen->capacity_in_bytes(), duke@435: gen->reserved().byte_size(), support_usage_threshold), _gen(gen) { duke@435: } duke@435: duke@435: MemoryUsage PSGenerationPool::get_memory_usage() { duke@435: size_t maxSize = (available_for_allocation() ? max_size() : 0); duke@435: size_t used = used_in_bytes(); duke@435: size_t committed = _gen->capacity_in_bytes(); duke@435: duke@435: return MemoryUsage(initial_size(), used, committed, maxSize); duke@435: } duke@435: duke@435: // The max size of EdenMutableSpacePool = duke@435: // max size of the PSYoungGen - capacity of two survivor spaces duke@435: // duke@435: // Max size of PS eden space is changing due to ergonomic. duke@435: // PSYoungGen, PSOldGen, Eden, Survivor spaces are all resizable. duke@435: // duke@435: EdenMutableSpacePool::EdenMutableSpacePool(PSYoungGen* gen, duke@435: MutableSpace* space, duke@435: const char* name, duke@435: PoolType type, duke@435: bool support_usage_threshold) : duke@435: CollectedMemoryPool(name, type, space->capacity_in_bytes(), duke@435: (gen->max_size() - gen->from_space()->capacity_in_bytes() - gen->to_space()->capacity_in_bytes()), duke@435: support_usage_threshold), duke@435: _gen(gen), _space(space) { duke@435: } duke@435: duke@435: MemoryUsage EdenMutableSpacePool::get_memory_usage() { duke@435: size_t maxSize = (available_for_allocation() ? max_size() : 0); duke@435: size_t used = used_in_bytes(); duke@435: size_t committed = _space->capacity_in_bytes(); duke@435: duke@435: return MemoryUsage(initial_size(), used, committed, maxSize); duke@435: } duke@435: duke@435: // The max size of SurvivorMutableSpacePool = duke@435: // current capacity of the from-space duke@435: // duke@435: // PS from and to survivor spaces could have different sizes. duke@435: // duke@435: SurvivorMutableSpacePool::SurvivorMutableSpacePool(PSYoungGen* gen, duke@435: const char* name, duke@435: PoolType type, duke@435: bool support_usage_threshold) : duke@435: CollectedMemoryPool(name, type, gen->from_space()->capacity_in_bytes(), duke@435: gen->from_space()->capacity_in_bytes(), duke@435: support_usage_threshold), _gen(gen) { duke@435: } duke@435: duke@435: MemoryUsage SurvivorMutableSpacePool::get_memory_usage() { duke@435: size_t maxSize = (available_for_allocation() ? max_size() : 0); duke@435: size_t used = used_in_bytes(); duke@435: size_t committed = committed_in_bytes(); duke@435: return MemoryUsage(initial_size(), used, committed, maxSize); duke@435: }