author | jmasa |
Thu, 21 Apr 2011 10:23:44 -0700 | |
changeset 9338 | 05ee447bd420 |
parent 7397 | 5b173b4ca846 |
child 10671 | 431ff8629f97 |
permissions | -rw-r--r-- |
4459 | 1 |
/* |
9338
05ee447bd420
6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
7397
diff
changeset
|
2 |
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
4459 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4463
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4463
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4463
diff
changeset
|
21 |
* questions. |
4459 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
26 |
#define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
|
27 |
||
28 |
#ifndef SERIALGC |
|
29 |
#include "services/memoryPool.hpp" |
|
30 |
#include "services/memoryUsage.hpp" |
|
31 |
#endif |
|
32 |
||
4459 | 33 |
class G1CollectedHeap; |
34 |
||
35 |
// This file contains the three classes that represent the memory |
|
36 |
// pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and |
|
37 |
// G1OldGenPool. In G1, unlike our other GCs, we do not have a |
|
38 |
// physical space for each of those spaces. Instead, we allocate |
|
39 |
// regions for all three spaces out of a single pool of regions (that |
|
40 |
// pool basically covers the entire heap). As a result, the eden, |
|
41 |
// survivor, and old gen are considered logical spaces in G1, as each |
|
42 |
// is a set of non-contiguous regions. This is also reflected in the |
|
43 |
// way we map them to memory pools here. The easiest way to have done |
|
44 |
// this would have been to map the entire G1 heap to a single memory |
|
45 |
// pool. However, it's helpful to show how large the eden and survivor |
|
46 |
// get, as this does affect the performance and behavior of G1. Which |
|
47 |
// is why we introduce the three memory pools implemented here. |
|
48 |
// |
|
9338
05ee447bd420
6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
7397
diff
changeset
|
49 |
// See comments in g1MonitoringSupport.hpp for additional details |
05ee447bd420
6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
7397
diff
changeset
|
50 |
// on this model. |
4459 | 51 |
// |
52 |
||
53 |
||
54 |
// This class is shared by the three G1 memory pool classes |
|
55 |
// (G1EdenPool, G1SurvivorPool, G1OldGenPool). Given that the way we |
|
56 |
// calculate used / committed bytes for these three pools is related |
|
57 |
// (see comment above), we put the calculations in this class so that |
|
58 |
// we can easily share them among the subclasses. |
|
59 |
class G1MemoryPoolSuper : public CollectedMemoryPool { |
|
60 |
protected: |
|
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
61 |
G1CollectedHeap* _g1h; |
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
62 |
|
4459 | 63 |
// Would only be called from subclasses. |
64 |
G1MemoryPoolSuper(G1CollectedHeap* g1h, |
|
65 |
const char* name, |
|
66 |
size_t init_size, |
|
67 |
bool support_usage_threshold); |
|
68 |
||
69 |
// The reason why all the code is in static methods is so that it |
|
70 |
// can be safely called from the constructors of the subclasses. |
|
71 |
||
6424
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
72 |
static size_t undefined_max() { |
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
73 |
return (size_t) -1; |
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
74 |
} |
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
75 |
|
4459 | 76 |
static size_t eden_space_committed(G1CollectedHeap* g1h); |
77 |
static size_t eden_space_used(G1CollectedHeap* g1h); |
|
78 |
||
79 |
static size_t survivor_space_committed(G1CollectedHeap* g1h); |
|
80 |
static size_t survivor_space_used(G1CollectedHeap* g1h); |
|
81 |
||
82 |
static size_t old_space_committed(G1CollectedHeap* g1h); |
|
83 |
static size_t old_space_used(G1CollectedHeap* g1h); |
|
84 |
}; |
|
85 |
||
86 |
// Memory pool that represents the G1 eden. |
|
87 |
class G1EdenPool : public G1MemoryPoolSuper { |
|
88 |
public: |
|
89 |
G1EdenPool(G1CollectedHeap* g1h); |
|
90 |
||
91 |
size_t used_in_bytes() { |
|
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
92 |
return eden_space_used(_g1h); |
4459 | 93 |
} |
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
94 |
size_t max_size() const { |
6424
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
95 |
return undefined_max(); |
4459 | 96 |
} |
97 |
MemoryUsage get_memory_usage(); |
|
98 |
}; |
|
99 |
||
100 |
// Memory pool that represents the G1 survivor. |
|
101 |
class G1SurvivorPool : public G1MemoryPoolSuper { |
|
102 |
public: |
|
103 |
G1SurvivorPool(G1CollectedHeap* g1h); |
|
104 |
||
105 |
size_t used_in_bytes() { |
|
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
106 |
return survivor_space_used(_g1h); |
4459 | 107 |
} |
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
108 |
size_t max_size() const { |
6424
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
109 |
return undefined_max(); |
4459 | 110 |
} |
111 |
MemoryUsage get_memory_usage(); |
|
112 |
}; |
|
113 |
||
114 |
// Memory pool that represents the G1 old gen. |
|
115 |
class G1OldGenPool : public G1MemoryPoolSuper { |
|
116 |
public: |
|
117 |
G1OldGenPool(G1CollectedHeap* g1h); |
|
118 |
||
119 |
size_t used_in_bytes() { |
|
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
120 |
return old_space_used(_g1h); |
4459 | 121 |
} |
4463
699f80df7faa
6906565: G1: deal with compilation warning in g1MemoryPool.hpp
tonyp
parents:
4462
diff
changeset
|
122 |
size_t max_size() const { |
6424
9ab433735f7c
6941275: G1: The MemoryPools are incorrectly supported for G1
tonyp
parents:
5547
diff
changeset
|
123 |
return undefined_max(); |
4459 | 124 |
} |
125 |
MemoryUsage get_memory_usage(); |
|
126 |
}; |
|
7397 | 127 |
|
128 |
#endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |