author | rkennke |
Thu, 30 Nov 2017 13:40:07 +0100 | |
changeset 48168 | cb5d2d4453d0 |
parent 47216 | 71c04702a3d5 |
child 50635 | 5d3c5af82654 |
child 55974 | 06122633fead |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2003, 2017, 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 |
||
30764 | 28 |
#include "gc/shared/gcCause.hpp" |
35061 | 29 |
#include "logging/log.hpp" |
7397 | 30 |
#include "memory/allocation.hpp" |
31 |
#include "runtime/handles.hpp" |
|
32 |
#include "services/memoryUsage.hpp" |
|
33 |
||
1 | 34 |
// Forward declaration |
35 |
class MemoryPool; |
|
36 |
class MemoryManager; |
|
37 |
class GCMemoryManager; |
|
38 |
class CollectedHeap; |
|
39 |
class CodeHeap; |
|
40 |
||
41 |
// VM Monitoring and Management Support |
|
42 |
||
43 |
class MemoryService : public AllStatic { |
|
44 |
private: |
|
45 |
enum { |
|
46 |
init_pools_list_size = 10, |
|
26796 | 47 |
init_managers_list_size = 5, |
48 |
init_code_heap_pools_size = 9 |
|
1 | 49 |
}; |
50 |
||
51 |
static GrowableArray<MemoryPool*>* _pools_list; |
|
52 |
static GrowableArray<MemoryManager*>* _managers_list; |
|
53 |
||
26796 | 54 |
// memory manager and code heap pools for the CodeCache |
55 |
static MemoryManager* _code_cache_manager; |
|
56 |
static GrowableArray<MemoryPool*>* _code_heap_pools; |
|
1 | 57 |
|
18444
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
58 |
static MemoryPool* _metaspace_pool; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
59 |
static MemoryPool* _compressed_class_pool; |
8adb4bc92f18
8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents:
16453
diff
changeset
|
60 |
|
1 | 61 |
public: |
62 |
static void set_universe_heap(CollectedHeap* heap); |
|
26796 | 63 |
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
|
64 |
static void add_metaspace_memory_pools(); |
1 | 65 |
|
66 |
static MemoryPool* get_memory_pool(instanceHandle pool); |
|
67 |
static MemoryManager* get_memory_manager(instanceHandle mgr); |
|
68 |
||
69 |
static const int num_memory_pools() { |
|
70 |
return _pools_list->length(); |
|
71 |
} |
|
72 |
static const int num_memory_managers() { |
|
73 |
return _managers_list->length(); |
|
74 |
} |
|
75 |
||
76 |
static MemoryPool* get_memory_pool(int index) { |
|
77 |
return _pools_list->at(index); |
|
78 |
} |
|
79 |
||
80 |
static MemoryManager* get_memory_manager(int index) { |
|
81 |
return _managers_list->at(index); |
|
82 |
} |
|
83 |
||
84 |
static void track_memory_usage(); |
|
85 |
static void track_code_cache_memory_usage() { |
|
26796 | 86 |
// Track memory pool usage of all CodeCache memory pools |
87 |
for (int i = 0; i < _code_heap_pools->length(); ++i) { |
|
88 |
track_memory_pool_usage(_code_heap_pools->at(i)); |
|
89 |
} |
|
1 | 90 |
} |
20407
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
91 |
static void track_metaspace_memory_usage() { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
92 |
track_memory_pool_usage(_metaspace_pool); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
93 |
} |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
94 |
static void track_compressed_class_memory_usage() { |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
95 |
track_memory_pool_usage(_compressed_class_pool); |
68e215ce8944
8025996: Track metaspace usage when metaspace is expanded
stefank
parents:
18444
diff
changeset
|
96 |
} |
1 | 97 |
static void track_memory_pool_usage(MemoryPool* pool); |
98 |
||
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
99 |
static void gc_begin(GCMemoryManager* manager, bool recordGCBeginTime, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
100 |
bool recordAccumulatedGCTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
101 |
bool recordPreGCUsage, bool recordPeakUsage); |
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
102 |
static void gc_end(GCMemoryManager* manager, bool recordPostGCUsage, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
103 |
bool recordAccumulatedGCTime, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
104 |
bool recordGCEndTime, bool countCollection, |
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
105 |
GCCause::Cause cause); |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
106 |
|
1 | 107 |
static void oops_do(OopClosure* f); |
108 |
||
35061 | 109 |
static bool get_verbose() { return log_is_enabled(Info, gc); } |
1 | 110 |
static bool set_verbose(bool verbose); |
111 |
||
112 |
// Create an instance of java/lang/management/MemoryUsage |
|
113 |
static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS); |
|
114 |
}; |
|
115 |
||
116 |
class TraceMemoryManagerStats : public StackObj { |
|
117 |
private: |
|
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
118 |
GCMemoryManager* _gc_memory_manager; |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
119 |
bool _recordGCBeginTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
120 |
bool _recordPreGCUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
121 |
bool _recordPeakUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
122 |
bool _recordPostGCUsage; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
123 |
bool _recordAccumulatedGCTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
124 |
bool _recordGCEndTime; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
125 |
bool _countCollection; |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
126 |
GCCause::Cause _cause; |
1 | 127 |
public: |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
128 |
TraceMemoryManagerStats() {} |
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
129 |
TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
130 |
GCCause::Cause cause, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
131 |
bool recordGCBeginTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
132 |
bool recordPreGCUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
133 |
bool recordPeakUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
134 |
bool recordPostGCUsage = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
135 |
bool recordAccumulatedGCTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
136 |
bool recordGCEndTime = true, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
137 |
bool countCollection = true); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
138 |
|
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47216
diff
changeset
|
139 |
void initialize(GCMemoryManager* gc_memory_manager, |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
7397
diff
changeset
|
140 |
GCCause::Cause cause, |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
141 |
bool recordGCBeginTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
142 |
bool recordPreGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
143 |
bool recordPeakUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
144 |
bool recordPostGCUsage, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
145 |
bool recordAccumulatedGCTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
146 |
bool recordGCEndTime, |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
147 |
bool countCollection); |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
148 |
|
1 | 149 |
~TraceMemoryManagerStats(); |
150 |
}; |
|
7397 | 151 |
|
152 |
#endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP |