src/share/vm/services/g1MemoryPool.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6198
55fb97c4c58d
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

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

mercurial