author | stefank |
Fri, 13 Feb 2015 14:37:35 +0100 | |
changeset 29081 | c61eb4914428 |
parent 26796 | 666464578742 |
child 29684 | a36d90acae41 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
20407
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, 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:
4459
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4459
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:
4459
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_SERVICES_MEMORYSERVICE_HPP |
26 |
#define SHARE_VM_SERVICES_MEMORYSERVICE_HPP |
|
27 |
||
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "memory/generation.hpp" |
|
30 |
#include "runtime/handles.hpp" |
|
31 |
#include "services/memoryUsage.hpp" |
|
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
32 |
#include "gc_interface/gcCause.hpp" |
7397 | 33 |
|
1 | 34 |
// Forward declaration |
35 |
class MemoryPool; |
|
36 |
class MemoryManager; |
|
37 |
class GCMemoryManager; |
|
38 |
class CollectedHeap; |
|
39 |
class Generation; |
|
40 |
class DefNewGeneration; |
|
41 |
class PSYoungGen; |
|
42 |
class PSOldGen; |
|
43 |
class CodeHeap; |
|
44 |
class ContiguousSpace; |
|
45 |
class CompactibleFreeListSpace; |
|
46 |
class GenCollectedHeap; |
|
47 |
class ParallelScavengeHeap; |
|
4459
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
48 |
class G1CollectedHeap; |
1 | 49 |
|
50 |
// VM Monitoring and Management Support |
|
51 |
||
52 |
class MemoryService : public AllStatic { |
|
53 |
private: |
|
54 |
enum { |
|
55 |
init_pools_list_size = 10, |
|
26796 | 56 |
init_managers_list_size = 5, |
57 |
init_code_heap_pools_size = 9 |
|
1 | 58 |
}; |
59 |
||
60 |
// index for minor and major generations |
|
61 |
enum { |
|
62 |
minor = 0, |
|
63 |
major = 1, |
|
64 |
n_gens = 2 |
|
65 |
}; |
|
66 |
||
67 |
static GrowableArray<MemoryPool*>* _pools_list; |
|
68 |
static GrowableArray<MemoryManager*>* _managers_list; |
|
69 |
||
70 |
// memory managers for minor and major GC statistics |
|
71 |
static GCMemoryManager* _major_gc_manager; |
|
72 |
static GCMemoryManager* _minor_gc_manager; |
|
73 |
||
26796 | 74 |
// memory manager and code heap pools for the CodeCache |
75 |
static MemoryManager* _code_cache_manager; |
|
76 |
static GrowableArray<MemoryPool*>* _code_heap_pools; |
|
1 | 77 |
|
18444
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
78 |
static MemoryPool* _metaspace_pool; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
79 |
static MemoryPool* _compressed_class_pool; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
80 |
|
1 | 81 |
static void add_generation_memory_pool(Generation* gen, |
82 |
MemoryManager* major_mgr, |
|
83 |
MemoryManager* minor_mgr); |
|
84 |
static void add_generation_memory_pool(Generation* gen, |
|
85 |
MemoryManager* major_mgr) { |
|
86 |
add_generation_memory_pool(gen, major_mgr, NULL); |
|
87 |
} |
|
88 |
||
89 |
||
90 |
static void add_psYoung_memory_pool(PSYoungGen* gen, |
|
91 |
MemoryManager* major_mgr, |
|
92 |
MemoryManager* minor_mgr); |
|
93 |
static void add_psOld_memory_pool(PSOldGen* gen, |
|
94 |
MemoryManager* mgr); |
|
95 |
||
4459
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
96 |
static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
97 |
MemoryManager* major_mgr, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
98 |
MemoryManager* minor_mgr); |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
99 |
static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h, |
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
100 |
MemoryManager* mgr); |
1 | 101 |
|
102 |
static MemoryPool* add_space(ContiguousSpace* space, |
|
103 |
const char* name, |
|
104 |
bool is_heap, |
|
105 |
size_t max_size, |
|
106 |
bool support_usage_threshold); |
|
107 |
static MemoryPool* add_survivor_spaces(DefNewGeneration* gen, |
|
108 |
const char* name, |
|
109 |
bool is_heap, |
|
110 |
size_t max_size, |
|
111 |
bool support_usage_threshold); |
|
112 |
static MemoryPool* add_gen(Generation* gen, |
|
113 |
const char* name, |
|
114 |
bool is_heap, |
|
115 |
bool support_usage_threshold); |
|
116 |
static MemoryPool* add_cms_space(CompactibleFreeListSpace* space, |
|
117 |
const char* name, |
|
118 |
bool is_heap, |
|
119 |
size_t max_size, |
|
120 |
bool support_usage_threshold); |
|
121 |
||
122 |
static void add_gen_collected_heap_info(GenCollectedHeap* heap); |
|
123 |
static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap); |
|
4459
eb506d590394
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1
diff
changeset
|
124 |
static void add_g1_heap_info(G1CollectedHeap* g1h); |
1 | 125 |
|
126 |
public: |
|
127 |
static void set_universe_heap(CollectedHeap* heap); |
|
26796 | 128 |
static void add_code_heap_memory_pool(CodeHeap* heap, const char* name); |
18444
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
129 |
static void add_metaspace_memory_pools(); |
1 | 130 |
|
131 |
static MemoryPool* get_memory_pool(instanceHandle pool); |
|
132 |
static MemoryManager* get_memory_manager(instanceHandle mgr); |
|
133 |
||
134 |
static const int num_memory_pools() { |
|
135 |
return _pools_list->length(); |
|
136 |
} |
|
137 |
static const int num_memory_managers() { |
|
138 |
return _managers_list->length(); |
|
139 |
} |
|
140 |
||
141 |
static MemoryPool* get_memory_pool(int index) { |
|
142 |
return _pools_list->at(index); |
|
143 |
} |
|
144 |
||
145 |
static MemoryManager* get_memory_manager(int index) { |
|
146 |
return _managers_list->at(index); |
|
147 |
} |
|
148 |
||
149 |
static void track_memory_usage(); |
|
150 |
static void track_code_cache_memory_usage() { |
|
26796 | 151 |
// Track memory pool usage of all CodeCache memory pools |
152 |
for (int i = 0; i < _code_heap_pools->length(); ++i) { |
|
153 |
track_memory_pool_usage(_code_heap_pools->at(i)); |
|
154 |
} |
|
1 | 155 |
} |
20407
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
156 |
static void track_metaspace_memory_usage() { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
157 |
track_memory_pool_usage(_metaspace_pool); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
158 |
} |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
159 |
static void track_compressed_class_memory_usage() { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
160 |
track_memory_pool_usage(_compressed_class_pool); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
161 |
} |
1 | 162 |
static void track_memory_pool_usage(MemoryPool* pool); |
163 |
||
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
164 |
static void gc_begin(bool fullGC, bool recordGCBeginTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
165 |
bool recordAccumulatedGCTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
166 |
bool recordPreGCUsage, bool recordPeakUsage); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
167 |
static void gc_end(bool fullGC, bool recordPostGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
168 |
bool recordAccumulatedGCTime, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
169 |
bool recordGCEndTime, bool countCollection, |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
170 |
GCCause::Cause cause); |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
171 |
|
1 | 172 |
|
173 |
static void oops_do(OopClosure* f); |
|
174 |
||
175 |
static bool get_verbose() { return PrintGC; } |
|
176 |
static bool set_verbose(bool verbose); |
|
177 |
||
178 |
// Create an instance of java/lang/management/MemoryUsage |
|
179 |
static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS); |
|
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
180 |
|
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
181 |
static const GCMemoryManager* get_minor_gc_manager() { |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
182 |
return _minor_gc_manager; |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
183 |
} |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
184 |
|
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
185 |
static const GCMemoryManager* get_major_gc_manager() { |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
186 |
return _major_gc_manager; |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
187 |
} |
1 | 188 |
}; |
189 |
||
190 |
class TraceMemoryManagerStats : public StackObj { |
|
191 |
private: |
|
192 |
bool _fullGC; |
|
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
193 |
bool _recordGCBeginTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
194 |
bool _recordPreGCUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
195 |
bool _recordPeakUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
196 |
bool _recordPostGCUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
197 |
bool _recordAccumulatedGCTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
198 |
bool _recordGCEndTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
199 |
bool _countCollection; |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
200 |
GCCause::Cause _cause; |
1 | 201 |
public: |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
202 |
TraceMemoryManagerStats() {} |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
203 |
TraceMemoryManagerStats(bool fullGC, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
204 |
GCCause::Cause cause, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
205 |
bool recordGCBeginTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
206 |
bool recordPreGCUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
207 |
bool recordPeakUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
208 |
bool recordPostGCUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
209 |
bool recordAccumulatedGCTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
210 |
bool recordGCEndTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
211 |
bool countCollection = true); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
212 |
|
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
213 |
void initialize(bool fullGC, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
214 |
GCCause::Cause cause, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
215 |
bool recordGCBeginTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
216 |
bool recordPreGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
217 |
bool recordPeakUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
218 |
bool recordPostGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
219 |
bool recordAccumulatedGCTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
220 |
bool recordGCEndTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
221 |
bool countCollection); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
222 |
|
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
223 |
TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause); |
1 | 224 |
~TraceMemoryManagerStats(); |
225 |
}; |
|
7397 | 226 |
|
227 |
#endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP |