author | dcubed |
Wed, 18 Sep 2019 20:49:13 -0400 | |
changeset 58223 | 778fc2dcbdaa |
parent 58177 | 4932dce35882 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51497
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
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:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51497
diff
changeset
|
25 |
#ifndef SHARE_SERVICES_MEMORYPOOL_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51497
diff
changeset
|
26 |
#define SHARE_SERVICES_MEMORYPOOL_HPP |
7397 | 27 |
|
28 |
#include "memory/heap.hpp" |
|
49658 | 29 |
#include "oops/oop.hpp" |
7397 | 30 |
#include "services/memoryUsage.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
13728
diff
changeset
|
31 |
#include "utilities/macros.hpp" |
7397 | 32 |
|
1 | 33 |
// A memory pool represents the memory area that the VM manages. |
34 |
// The Java virtual machine has at least one memory pool |
|
35 |
// and it may create or remove memory pools during execution. |
|
36 |
// A memory pool can belong to the heap or the non-heap memory. |
|
37 |
// A Java virtual machine may also have memory pools belonging to |
|
38 |
// both heap and non-heap memory. |
|
39 |
||
40 |
// Forward declaration |
|
41 |
class MemoryManager; |
|
42 |
class SensorInfo; |
|
43 |
class ThresholdSupport; |
|
44 |
||
13195 | 45 |
class MemoryPool : public CHeapObj<mtInternal> { |
1 | 46 |
friend class MemoryManager; |
47 |
public: |
|
48 |
enum PoolType { |
|
49 |
Heap = 1, |
|
50 |
NonHeap = 2 |
|
51 |
}; |
|
52 |
||
53 |
private: |
|
54 |
enum { |
|
55 |
max_num_managers = 5 |
|
56 |
}; |
|
57 |
||
58 |
// We could make some of the following as performance counters |
|
59 |
// for external monitoring. |
|
60 |
const char* _name; |
|
61 |
PoolType _type; |
|
62 |
size_t _initial_size; |
|
63 |
size_t _max_size; |
|
64 |
bool _available_for_allocation; // Default is true |
|
65 |
MemoryManager* _managers[max_num_managers]; |
|
66 |
int _num_managers; |
|
67 |
MemoryUsage _peak_usage; // Peak memory usage |
|
68 |
MemoryUsage _after_gc_usage; // After GC memory usage |
|
69 |
||
70 |
ThresholdSupport* _usage_threshold; |
|
71 |
ThresholdSupport* _gc_usage_threshold; |
|
72 |
||
73 |
SensorInfo* _usage_sensor; |
|
74 |
SensorInfo* _gc_usage_sensor; |
|
75 |
||
76 |
volatile instanceOop _memory_pool_obj; |
|
77 |
||
78 |
void add_manager(MemoryManager* mgr); |
|
79 |
||
80 |
public: |
|
81 |
MemoryPool(const char* name, |
|
82 |
PoolType type, |
|
83 |
size_t init_size, |
|
84 |
size_t max_size, |
|
85 |
bool support_usage_threshold, |
|
86 |
bool support_gc_threshold); |
|
87 |
||
51497
ec014e5694ec
8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents:
49658
diff
changeset
|
88 |
virtual ~MemoryPool() { } |
ec014e5694ec
8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents:
49658
diff
changeset
|
89 |
|
1 | 90 |
const char* name() { return _name; } |
91 |
bool is_heap() { return _type == Heap; } |
|
92 |
bool is_non_heap() { return _type == NonHeap; } |
|
93 |
size_t initial_size() const { return _initial_size; } |
|
94 |
int num_memory_managers() const { return _num_managers; } |
|
95 |
// max size could be changed |
|
96 |
virtual size_t max_size() const { return _max_size; } |
|
97 |
||
58177 | 98 |
bool is_pool(instanceHandle pool) { return pool() == _memory_pool_obj; } |
1 | 99 |
|
100 |
bool available_for_allocation() { return _available_for_allocation; } |
|
101 |
bool set_available_for_allocation(bool value) { |
|
102 |
bool prev = _available_for_allocation; |
|
103 |
_available_for_allocation = value; |
|
104 |
return prev; |
|
105 |
} |
|
106 |
||
107 |
MemoryManager* get_memory_manager(int index) { |
|
108 |
assert(index >= 0 && index < _num_managers, "Invalid index"); |
|
109 |
return _managers[index]; |
|
110 |
} |
|
111 |
||
112 |
// Records current memory usage if it's a peak usage |
|
113 |
void record_peak_memory_usage(); |
|
114 |
||
115 |
MemoryUsage get_peak_memory_usage() { |
|
116 |
// check current memory usage first and then return peak usage |
|
117 |
record_peak_memory_usage(); |
|
118 |
return _peak_usage; |
|
119 |
} |
|
120 |
void reset_peak_memory_usage() { |
|
121 |
_peak_usage = get_memory_usage(); |
|
122 |
} |
|
123 |
||
124 |
ThresholdSupport* usage_threshold() { return _usage_threshold; } |
|
125 |
ThresholdSupport* gc_usage_threshold() { return _gc_usage_threshold; } |
|
126 |
||
127 |
SensorInfo* usage_sensor() { return _usage_sensor; } |
|
128 |
SensorInfo* gc_usage_sensor() { return _gc_usage_sensor; } |
|
129 |
||
130 |
void set_usage_sensor_obj(instanceHandle s); |
|
131 |
void set_gc_usage_sensor_obj(instanceHandle s); |
|
132 |
void set_last_collection_usage(MemoryUsage u) { _after_gc_usage = u; } |
|
133 |
||
134 |
virtual instanceOop get_memory_pool_instance(TRAPS); |
|
135 |
virtual MemoryUsage get_memory_usage() = 0; |
|
136 |
virtual size_t used_in_bytes() = 0; |
|
137 |
virtual bool is_collected_pool() { return false; } |
|
138 |
virtual MemoryUsage get_last_collection_usage() { return _after_gc_usage; } |
|
139 |
||
140 |
// GC support |
|
141 |
void oops_do(OopClosure* f); |
|
142 |
}; |
|
143 |
||
144 |
class CollectedMemoryPool : public MemoryPool { |
|
145 |
public: |
|
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
146 |
CollectedMemoryPool(const char* name, size_t init_size, size_t max_size, bool support_usage_threshold) : |
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
147 |
MemoryPool(name, MemoryPool::Heap, init_size, max_size, support_usage_threshold, true) {}; |
1 | 148 |
bool is_collected_pool() { return true; } |
149 |
}; |
|
150 |
||
151 |
class CodeHeapPool: public MemoryPool { |
|
152 |
private: |
|
153 |
CodeHeap* _codeHeap; |
|
154 |
public: |
|
155 |
CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_usage_threshold); |
|
156 |
MemoryUsage get_memory_usage(); |
|
157 |
size_t used_in_bytes() { return _codeHeap->allocated_capacity(); } |
|
158 |
}; |
|
7397 | 159 |
|
18444
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
160 |
class MetaspacePool : public MemoryPool { |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
161 |
size_t calculate_max_size() const; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
162 |
public: |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
163 |
MetaspacePool(); |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
164 |
MemoryUsage get_memory_usage(); |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
165 |
size_t used_in_bytes(); |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
166 |
}; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
167 |
|
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
168 |
class CompressedKlassSpacePool : public MemoryPool { |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
169 |
public: |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
170 |
CompressedKlassSpacePool(); |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
171 |
MemoryUsage get_memory_usage(); |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
172 |
size_t used_in_bytes(); |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
173 |
}; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
174 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51497
diff
changeset
|
175 |
#endif // SHARE_SERVICES_MEMORYPOOL_HPP |