annotate src/share/vm/services/g1MemoryPool.hpp @ 1092:ed52bcc32739

6880903: G1: G1 reports incorrect Runtime.maxMemory() Summary: G1 reports committed memory instead of reserved memory from the Runtime.maxMemory() method Reviewed-by: ysr, jmasa
author tonyp
date Fri, 04 Dec 2009 07:44:35 -0500
parents db0d5eba9d20
children afc30fccf324
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1089
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
1 /*
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
2 * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
4 *
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
7 * published by the Free Software Foundation.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
8 *
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
13 * accompanied this code).
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
14 *
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
18 *
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
21 * have any questions.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
22 *
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
23 */
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
24
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
25 class G1CollectedHeap;
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
26
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
27 // This file contains the three classes that represent the memory
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
28 // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
29 // G1OldGenPool. In G1, unlike our other GCs, we do not have a
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
30 // physical space for each of those spaces. Instead, we allocate
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
31 // regions for all three spaces out of a single pool of regions (that
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
32 // pool basically covers the entire heap). As a result, the eden,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
33 // survivor, and old gen are considered logical spaces in G1, as each
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
34 // is a set of non-contiguous regions. This is also reflected in the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
35 // way we map them to memory pools here. The easiest way to have done
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
36 // this would have been to map the entire G1 heap to a single memory
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
37 // pool. However, it's helpful to show how large the eden and survivor
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
38 // get, as this does affect the performance and behavior of G1. Which
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
39 // is why we introduce the three memory pools implemented here.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
40 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
41 // The above approach inroduces a couple of challenging issues in the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
42 // implementation of the three memory pools:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
43 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
44 // 1) The used space calculation for a pool is not necessarily
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
45 // independent of the others. We can easily get from G1 the overall
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
46 // used space in the entire heap, the number of regions in the young
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
47 // generation (includes both eden and survivors), and the number of
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
48 // survivor regions. So, from that we calculate:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
49 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
50 // survivor_used = survivor_num * region_size
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
51 // eden_used = young_region_num * region_size - survivor_used
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
52 // old_gen_used = overall_used - eden_used - survivor_used
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
53 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
54 // Note that survivor_used and eden_used are upper bounds. To get the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
55 // actual value we would have to iterate over the regions and add up
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
56 // ->used(). But that'd be expensive. So, we'll accept some lack of
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
57 // accuracy for those two. But, we have to be careful when calculating
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
58 // old_gen_used, in case we subtract from overall_used more then the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
59 // actual number and our result goes negative.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
60 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
61 // 2) Calculating the used space is straightforward, as described
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
62 // above. However, how do we calculate the committed space, given that
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
63 // we allocate space for the eden, survivor, and old gen out of the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
64 // same pool of regions? One way to do this is to use the used value
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
65 // as also the committed value for the eden and survivor spaces and
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
66 // then calculate the old gen committed space as follows:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
67 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
68 // old_gen_committed = overall_committed - eden_committed - survivor_committed
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
69 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
70 // Maybe a better way to do that would be to calculate used for eden
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
71 // and survivor as a sum of ->used() over their regions and then
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
72 // calculate committed as region_num * region_size (i.e., what we use
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
73 // to calculate the used space now). This is something to consider
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
74 // in the future.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
75 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
76 // 3) Another decision that is again not straightforward is what is
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
77 // the max size that each memory pool can grow to. Right now, we set
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
78 // that the committed size for the eden and the survivors and
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
79 // calculate the old gen max as follows (basically, it's a similar
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
80 // pattern to what we use for the committed space, as described
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
81 // above):
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
82 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
83 // old_gen_max = overall_max - eden_max - survivor_max
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
84 //
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
85 // 4) Now, there is a very subtle issue with all the above. The
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
86 // framework will call get_memory_usage() on the three pools
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
87 // asynchronously. As a result, each call might get a different value
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
88 // for, say, survivor_num which will yield inconsistent values for
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
89 // eden_used, survivor_used, and old_gen_used (as survivor_num is used
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
90 // in the calculation of all three). This would normally be
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
91 // ok. However, it's possible that this might cause the sum of
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
92 // eden_used, survivor_used, and old_gen_used to go over the max heap
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
93 // size and this seems to sometimes cause JConsole (and maybe other
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
94 // clients) to get confused. There's not a really an easy / clean
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
95 // solution to this problem, due to the asynchrounous nature of the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
96 // framework.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
97
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
98
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
99 // This class is shared by the three G1 memory pool classes
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
100 // (G1EdenPool, G1SurvivorPool, G1OldGenPool). Given that the way we
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
101 // calculate used / committed bytes for these three pools is related
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
102 // (see comment above), we put the calculations in this class so that
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
103 // we can easily share them among the subclasses.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
104 class G1MemoryPoolSuper : public CollectedMemoryPool {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
105 private:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
106 G1CollectedHeap* _g1h;
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
107
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
108 // It returns x - y if x > y, 0 otherwise.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
109 // As described in the comment above, some of the inputs to the
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
110 // calculations we have to do are obtained concurrently and hence
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
111 // may be inconsistent with each other. So, this provides a
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
112 // defensive way of performing the subtraction and avoids the value
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
113 // going negative (which would mean a very large result, given that
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
114 // the parameter are size_t).
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
115 static size_t subtract_up_to_zero(size_t x, size_t y) {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
116 if (x > y) {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
117 return x - y;
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
118 } else {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
119 return 0;
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
120 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
121 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
122
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
123 protected:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
124 // Would only be called from subclasses.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
125 G1MemoryPoolSuper(G1CollectedHeap* g1h,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
126 const char* name,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
127 size_t init_size,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
128 size_t max_size,
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
129 bool support_usage_threshold);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
130
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
131 // The reason why all the code is in static methods is so that it
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
132 // can be safely called from the constructors of the subclasses.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
133
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
134 static size_t overall_committed(G1CollectedHeap* g1h) {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
135 return g1h->capacity();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
136 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
137 static size_t overall_used(G1CollectedHeap* g1h) {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
138 return g1h->used_unlocked();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
139 }
1092
ed52bcc32739 6880903: G1: G1 reports incorrect Runtime.maxMemory()
tonyp
parents: 1089
diff changeset
140 static size_t overall_max(G1CollectedHeap* g1h) {
ed52bcc32739 6880903: G1: G1 reports incorrect Runtime.maxMemory()
tonyp
parents: 1089
diff changeset
141 return g1h->g1_reserved_obj_bytes();
ed52bcc32739 6880903: G1: G1 reports incorrect Runtime.maxMemory()
tonyp
parents: 1089
diff changeset
142 }
1089
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
143
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
144 static size_t eden_space_committed(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
145 static size_t eden_space_used(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
146 static size_t eden_space_max(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
147
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
148 static size_t survivor_space_committed(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
149 static size_t survivor_space_used(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
150 static size_t survivor_space_max(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
151
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
152 static size_t old_space_committed(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
153 static size_t old_space_used(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
154 static size_t old_space_max(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
155
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
156 // The non-static versions are included for convenience.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
157
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
158 size_t eden_space_committed() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
159 return eden_space_committed(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
160 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
161 size_t eden_space_used() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
162 return eden_space_used(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
163 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
164 size_t eden_space_max() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
165 return eden_space_max(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
166 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
167
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
168 size_t survivor_space_committed() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
169 return survivor_space_committed(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
170 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
171 size_t survivor_space_used() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
172 return survivor_space_used(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
173 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
174 size_t survivor_space_max() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
175 return survivor_space_max(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
176 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
177
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
178 size_t old_space_committed() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
179 return old_space_committed(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
180 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
181 size_t old_space_used() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
182 return old_space_used(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
183 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
184 size_t old_space_max() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
185 return old_space_max(_g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
186 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
187 };
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
188
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
189 // Memory pool that represents the G1 eden.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
190 class G1EdenPool : public G1MemoryPoolSuper {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
191 public:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
192 G1EdenPool(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
193
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
194 size_t used_in_bytes() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
195 return eden_space_used();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
196 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
197 size_t max_size() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
198 return eden_space_max();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
199 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
200 MemoryUsage get_memory_usage();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
201 };
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
202
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
203 // Memory pool that represents the G1 survivor.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
204 class G1SurvivorPool : public G1MemoryPoolSuper {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
205 public:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
206 G1SurvivorPool(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
207
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
208 size_t used_in_bytes() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
209 return survivor_space_used();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
210 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
211 size_t max_size() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
212 return survivor_space_max();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
213 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
214 MemoryUsage get_memory_usage();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
215 };
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
216
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
217 // Memory pool that represents the G1 old gen.
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
218 class G1OldGenPool : public G1MemoryPoolSuper {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
219 public:
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
220 G1OldGenPool(G1CollectedHeap* g1h);
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
221
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
222 size_t used_in_bytes() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
223 return old_space_used();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
224 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
225 size_t max_size() {
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
226 return old_space_max();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
227 }
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
228 MemoryUsage get_memory_usage();
db0d5eba9d20 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
diff changeset
229 };