tonyp@1524: /* mikael@4153: * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. tonyp@1524: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. tonyp@1524: * tonyp@1524: * This code is free software; you can redistribute it and/or modify it tonyp@1524: * under the terms of the GNU General Public License version 2 only, as tonyp@1524: * published by the Free Software Foundation. tonyp@1524: * tonyp@1524: * This code is distributed in the hope that it will be useful, but WITHOUT tonyp@1524: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or tonyp@1524: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License tonyp@1524: * version 2 for more details (a copy is included in the LICENSE file that tonyp@1524: * accompanied this code). tonyp@1524: * tonyp@1524: * You should have received a copy of the GNU General Public License version tonyp@1524: * 2 along with this work; if not, write to the Free Software Foundation, tonyp@1524: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. tonyp@1524: * 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. tonyp@1524: * tonyp@1524: */ tonyp@1524: stefank@2314: #ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP stefank@2314: #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP stefank@2314: jprovino@4542: #include "utilities/macros.hpp" jprovino@4542: #if INCLUDE_ALL_GCS tonyp@3176: #include "gc_implementation/g1/g1MonitoringSupport.hpp" stefank@2314: #include "services/memoryPool.hpp" stefank@2314: #include "services/memoryUsage.hpp" jprovino@4542: #endif // INCLUDE_ALL_GCS stefank@2314: tonyp@1524: // This file contains the three classes that represent the memory tonyp@1524: // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and tonyp@1524: // G1OldGenPool. In G1, unlike our other GCs, we do not have a tonyp@1524: // physical space for each of those spaces. Instead, we allocate tonyp@1524: // regions for all three spaces out of a single pool of regions (that tonyp@1524: // pool basically covers the entire heap). As a result, the eden, tonyp@1524: // survivor, and old gen are considered logical spaces in G1, as each tonyp@1524: // is a set of non-contiguous regions. This is also reflected in the tonyp@1524: // way we map them to memory pools here. The easiest way to have done tonyp@1524: // this would have been to map the entire G1 heap to a single memory tonyp@1524: // pool. However, it's helpful to show how large the eden and survivor tonyp@1524: // get, as this does affect the performance and behavior of G1. Which tonyp@1524: // is why we introduce the three memory pools implemented here. tonyp@1524: // jmasa@2821: // See comments in g1MonitoringSupport.hpp for additional details jmasa@2821: // on this model. tonyp@1524: // tonyp@1524: tonyp@1524: // This class is shared by the three G1 memory pool classes tonyp@3176: // (G1EdenPool, G1SurvivorPool, G1OldGenPool). tonyp@1524: class G1MemoryPoolSuper : public CollectedMemoryPool { tonyp@1524: protected: tonyp@3176: const static size_t _undefined_max = (size_t) -1; tonyp@3176: G1MonitoringSupport* _g1mm; tonyp@1528: tonyp@1524: // Would only be called from subclasses. tonyp@1524: G1MemoryPoolSuper(G1CollectedHeap* g1h, tonyp@1524: const char* name, tonyp@1524: size_t init_size, tonyp@3176: size_t max_size, tonyp@1524: bool support_usage_threshold); tonyp@1524: }; tonyp@1524: tonyp@1524: // Memory pool that represents the G1 eden. tonyp@1524: class G1EdenPool : public G1MemoryPoolSuper { tonyp@1524: public: tonyp@1524: G1EdenPool(G1CollectedHeap* g1h); tonyp@1524: tonyp@1524: size_t used_in_bytes() { tonyp@3176: return _g1mm->eden_space_used(); tonyp@1524: } tonyp@1528: size_t max_size() const { tonyp@3176: return _undefined_max; tonyp@1524: } tonyp@1524: MemoryUsage get_memory_usage(); tonyp@1524: }; tonyp@1524: tonyp@1524: // Memory pool that represents the G1 survivor. tonyp@1524: class G1SurvivorPool : public G1MemoryPoolSuper { tonyp@1524: public: tonyp@1524: G1SurvivorPool(G1CollectedHeap* g1h); tonyp@1524: tonyp@1524: size_t used_in_bytes() { tonyp@3176: return _g1mm->survivor_space_used(); tonyp@1524: } tonyp@1528: size_t max_size() const { tonyp@3176: return _undefined_max; tonyp@1524: } tonyp@1524: MemoryUsage get_memory_usage(); tonyp@1524: }; tonyp@1524: tonyp@1524: // Memory pool that represents the G1 old gen. tonyp@1524: class G1OldGenPool : public G1MemoryPoolSuper { tonyp@1524: public: tonyp@1524: G1OldGenPool(G1CollectedHeap* g1h); tonyp@1524: tonyp@1524: size_t used_in_bytes() { tonyp@3176: return _g1mm->old_space_used(); tonyp@1524: } tonyp@1528: size_t max_size() const { tonyp@3459: return _g1mm->old_gen_max(); tonyp@1524: } tonyp@1524: MemoryUsage get_memory_usage(); tonyp@1524: }; stefank@2314: stefank@2314: #endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP