Thu, 19 Jan 2012 09:13:58 -0500
7078465: G1: Don't use the undefined value (-1) for the G1 old memory pool max size
Reviewed-by: johnc, brutisso
tonyp@1524 | 1 | /* |
jmasa@2821 | 2 | * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
tonyp@1524 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tonyp@1524 | 4 | * |
tonyp@1524 | 5 | * This code is free software; you can redistribute it and/or modify it |
tonyp@1524 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tonyp@1524 | 7 | * published by the Free Software Foundation. |
tonyp@1524 | 8 | * |
tonyp@1524 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tonyp@1524 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tonyp@1524 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tonyp@1524 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tonyp@1524 | 13 | * accompanied this code). |
tonyp@1524 | 14 | * |
tonyp@1524 | 15 | * You should have received a copy of the GNU General Public License version |
tonyp@1524 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tonyp@1524 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tonyp@1524 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
tonyp@1524 | 22 | * |
tonyp@1524 | 23 | */ |
tonyp@1524 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
stefank@2314 | 26 | #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #ifndef SERIALGC |
tonyp@3176 | 29 | #include "gc_implementation/g1/g1MonitoringSupport.hpp" |
stefank@2314 | 30 | #include "services/memoryPool.hpp" |
stefank@2314 | 31 | #include "services/memoryUsage.hpp" |
stefank@2314 | 32 | #endif |
stefank@2314 | 33 | |
tonyp@1524 | 34 | // This file contains the three classes that represent the memory |
tonyp@1524 | 35 | // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and |
tonyp@1524 | 36 | // G1OldGenPool. In G1, unlike our other GCs, we do not have a |
tonyp@1524 | 37 | // physical space for each of those spaces. Instead, we allocate |
tonyp@1524 | 38 | // regions for all three spaces out of a single pool of regions (that |
tonyp@1524 | 39 | // pool basically covers the entire heap). As a result, the eden, |
tonyp@1524 | 40 | // survivor, and old gen are considered logical spaces in G1, as each |
tonyp@1524 | 41 | // is a set of non-contiguous regions. This is also reflected in the |
tonyp@1524 | 42 | // way we map them to memory pools here. The easiest way to have done |
tonyp@1524 | 43 | // this would have been to map the entire G1 heap to a single memory |
tonyp@1524 | 44 | // pool. However, it's helpful to show how large the eden and survivor |
tonyp@1524 | 45 | // get, as this does affect the performance and behavior of G1. Which |
tonyp@1524 | 46 | // is why we introduce the three memory pools implemented here. |
tonyp@1524 | 47 | // |
jmasa@2821 | 48 | // See comments in g1MonitoringSupport.hpp for additional details |
jmasa@2821 | 49 | // on this model. |
tonyp@1524 | 50 | // |
tonyp@1524 | 51 | |
tonyp@1524 | 52 | // This class is shared by the three G1 memory pool classes |
tonyp@3176 | 53 | // (G1EdenPool, G1SurvivorPool, G1OldGenPool). |
tonyp@1524 | 54 | class G1MemoryPoolSuper : public CollectedMemoryPool { |
tonyp@1524 | 55 | protected: |
tonyp@3176 | 56 | const static size_t _undefined_max = (size_t) -1; |
tonyp@3176 | 57 | G1MonitoringSupport* _g1mm; |
tonyp@1528 | 58 | |
tonyp@1524 | 59 | // Would only be called from subclasses. |
tonyp@1524 | 60 | G1MemoryPoolSuper(G1CollectedHeap* g1h, |
tonyp@1524 | 61 | const char* name, |
tonyp@1524 | 62 | size_t init_size, |
tonyp@3176 | 63 | size_t max_size, |
tonyp@1524 | 64 | bool support_usage_threshold); |
tonyp@1524 | 65 | }; |
tonyp@1524 | 66 | |
tonyp@1524 | 67 | // Memory pool that represents the G1 eden. |
tonyp@1524 | 68 | class G1EdenPool : public G1MemoryPoolSuper { |
tonyp@1524 | 69 | public: |
tonyp@1524 | 70 | G1EdenPool(G1CollectedHeap* g1h); |
tonyp@1524 | 71 | |
tonyp@1524 | 72 | size_t used_in_bytes() { |
tonyp@3176 | 73 | return _g1mm->eden_space_used(); |
tonyp@1524 | 74 | } |
tonyp@1528 | 75 | size_t max_size() const { |
tonyp@3176 | 76 | return _undefined_max; |
tonyp@1524 | 77 | } |
tonyp@1524 | 78 | MemoryUsage get_memory_usage(); |
tonyp@1524 | 79 | }; |
tonyp@1524 | 80 | |
tonyp@1524 | 81 | // Memory pool that represents the G1 survivor. |
tonyp@1524 | 82 | class G1SurvivorPool : public G1MemoryPoolSuper { |
tonyp@1524 | 83 | public: |
tonyp@1524 | 84 | G1SurvivorPool(G1CollectedHeap* g1h); |
tonyp@1524 | 85 | |
tonyp@1524 | 86 | size_t used_in_bytes() { |
tonyp@3176 | 87 | return _g1mm->survivor_space_used(); |
tonyp@1524 | 88 | } |
tonyp@1528 | 89 | size_t max_size() const { |
tonyp@3176 | 90 | return _undefined_max; |
tonyp@1524 | 91 | } |
tonyp@1524 | 92 | MemoryUsage get_memory_usage(); |
tonyp@1524 | 93 | }; |
tonyp@1524 | 94 | |
tonyp@1524 | 95 | // Memory pool that represents the G1 old gen. |
tonyp@1524 | 96 | class G1OldGenPool : public G1MemoryPoolSuper { |
tonyp@1524 | 97 | public: |
tonyp@1524 | 98 | G1OldGenPool(G1CollectedHeap* g1h); |
tonyp@1524 | 99 | |
tonyp@1524 | 100 | size_t used_in_bytes() { |
tonyp@3176 | 101 | return _g1mm->old_space_used(); |
tonyp@1524 | 102 | } |
tonyp@1528 | 103 | size_t max_size() const { |
tonyp@3459 | 104 | return _g1mm->old_gen_max(); |
tonyp@1524 | 105 | } |
tonyp@1524 | 106 | MemoryUsage get_memory_usage(); |
tonyp@1524 | 107 | }; |
stefank@2314 | 108 | |
stefank@2314 | 109 | #endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |