src/share/vm/services/memoryService.hpp

Mon, 19 Aug 2013 18:17:58 +0200

author
ehelin
date
Mon, 19 Aug 2013 18:17:58 +0200
changeset 5552
422920730903
parent 5312
71963b3f802a
child 5864
a6414751d537
permissions
-rw-r--r--

8023219: NPG: MetaspaceMemoryPool should report statistics for all of metaspace
Reviewed-by: stefank, sjohanss

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_SERVICES_MEMORYSERVICE_HPP
stefank@2314 26 #define SHARE_VM_SERVICES_MEMORYSERVICE_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "memory/generation.hpp"
stefank@2314 30 #include "runtime/handles.hpp"
stefank@2314 31 #include "services/memoryUsage.hpp"
fparain@2888 32 #include "gc_interface/gcCause.hpp"
stefank@2314 33
duke@435 34 // Forward declaration
duke@435 35 class MemoryPool;
duke@435 36 class MemoryManager;
duke@435 37 class GCMemoryManager;
duke@435 38 class CollectedHeap;
duke@435 39 class Generation;
duke@435 40 class DefNewGeneration;
duke@435 41 class PSYoungGen;
duke@435 42 class PSOldGen;
duke@435 43 class CodeHeap;
duke@435 44 class ContiguousSpace;
duke@435 45 class CompactibleFreeListSpace;
duke@435 46 class GenCollectedHeap;
duke@435 47 class ParallelScavengeHeap;
tonyp@1524 48 class G1CollectedHeap;
duke@435 49
duke@435 50 // VM Monitoring and Management Support
duke@435 51
duke@435 52 class MemoryService : public AllStatic {
duke@435 53 private:
duke@435 54 enum {
duke@435 55 init_pools_list_size = 10,
duke@435 56 init_managers_list_size = 5
duke@435 57 };
duke@435 58
duke@435 59 // index for minor and major generations
duke@435 60 enum {
duke@435 61 minor = 0,
duke@435 62 major = 1,
duke@435 63 n_gens = 2
duke@435 64 };
duke@435 65
duke@435 66 static GrowableArray<MemoryPool*>* _pools_list;
duke@435 67 static GrowableArray<MemoryManager*>* _managers_list;
duke@435 68
duke@435 69 // memory managers for minor and major GC statistics
duke@435 70 static GCMemoryManager* _major_gc_manager;
duke@435 71 static GCMemoryManager* _minor_gc_manager;
duke@435 72
duke@435 73 // Code heap memory pool
duke@435 74 static MemoryPool* _code_heap_pool;
duke@435 75
ehelin@5312 76 static MemoryPool* _metaspace_pool;
ehelin@5312 77 static MemoryPool* _compressed_class_pool;
ehelin@5312 78
duke@435 79 static void add_generation_memory_pool(Generation* gen,
duke@435 80 MemoryManager* major_mgr,
duke@435 81 MemoryManager* minor_mgr);
duke@435 82 static void add_generation_memory_pool(Generation* gen,
duke@435 83 MemoryManager* major_mgr) {
duke@435 84 add_generation_memory_pool(gen, major_mgr, NULL);
duke@435 85 }
duke@435 86
duke@435 87
duke@435 88 static void add_psYoung_memory_pool(PSYoungGen* gen,
duke@435 89 MemoryManager* major_mgr,
duke@435 90 MemoryManager* minor_mgr);
duke@435 91 static void add_psOld_memory_pool(PSOldGen* gen,
duke@435 92 MemoryManager* mgr);
duke@435 93
tonyp@1524 94 static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 95 MemoryManager* major_mgr,
tonyp@1524 96 MemoryManager* minor_mgr);
tonyp@1524 97 static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 98 MemoryManager* mgr);
duke@435 99
duke@435 100 static MemoryPool* add_space(ContiguousSpace* space,
duke@435 101 const char* name,
duke@435 102 bool is_heap,
duke@435 103 size_t max_size,
duke@435 104 bool support_usage_threshold);
duke@435 105 static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
duke@435 106 const char* name,
duke@435 107 bool is_heap,
duke@435 108 size_t max_size,
duke@435 109 bool support_usage_threshold);
duke@435 110 static MemoryPool* add_gen(Generation* gen,
duke@435 111 const char* name,
duke@435 112 bool is_heap,
duke@435 113 bool support_usage_threshold);
duke@435 114 static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
duke@435 115 const char* name,
duke@435 116 bool is_heap,
duke@435 117 size_t max_size,
duke@435 118 bool support_usage_threshold);
duke@435 119
duke@435 120 static void add_gen_collected_heap_info(GenCollectedHeap* heap);
duke@435 121 static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
tonyp@1524 122 static void add_g1_heap_info(G1CollectedHeap* g1h);
duke@435 123
duke@435 124 public:
duke@435 125 static void set_universe_heap(CollectedHeap* heap);
duke@435 126 static void add_code_heap_memory_pool(CodeHeap* heap);
ehelin@5312 127 static void add_metaspace_memory_pools();
duke@435 128
duke@435 129 static MemoryPool* get_memory_pool(instanceHandle pool);
duke@435 130 static MemoryManager* get_memory_manager(instanceHandle mgr);
duke@435 131
duke@435 132 static const int num_memory_pools() {
duke@435 133 return _pools_list->length();
duke@435 134 }
duke@435 135 static const int num_memory_managers() {
duke@435 136 return _managers_list->length();
duke@435 137 }
duke@435 138
duke@435 139 static MemoryPool* get_memory_pool(int index) {
duke@435 140 return _pools_list->at(index);
duke@435 141 }
duke@435 142
duke@435 143 static MemoryManager* get_memory_manager(int index) {
duke@435 144 return _managers_list->at(index);
duke@435 145 }
duke@435 146
duke@435 147 static void track_memory_usage();
duke@435 148 static void track_code_cache_memory_usage() {
duke@435 149 track_memory_pool_usage(_code_heap_pool);
duke@435 150 }
duke@435 151 static void track_memory_pool_usage(MemoryPool* pool);
duke@435 152
kevinw@2058 153 static void gc_begin(bool fullGC, bool recordGCBeginTime,
kevinw@2058 154 bool recordAccumulatedGCTime,
kevinw@2058 155 bool recordPreGCUsage, bool recordPeakUsage);
kevinw@2058 156 static void gc_end(bool fullGC, bool recordPostGCUsage,
kevinw@2058 157 bool recordAccumulatedGCTime,
fparain@2888 158 bool recordGCEndTime, bool countCollection,
fparain@2888 159 GCCause::Cause cause);
kevinw@2058 160
duke@435 161
duke@435 162 static void oops_do(OopClosure* f);
duke@435 163
duke@435 164 static bool get_verbose() { return PrintGC; }
duke@435 165 static bool set_verbose(bool verbose);
duke@435 166
duke@435 167 // Create an instance of java/lang/management/MemoryUsage
duke@435 168 static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
fparain@2888 169
fparain@2888 170 static const GCMemoryManager* get_minor_gc_manager() {
fparain@2888 171 return _minor_gc_manager;
fparain@2888 172 }
fparain@2888 173
fparain@2888 174 static const GCMemoryManager* get_major_gc_manager() {
fparain@2888 175 return _major_gc_manager;
fparain@2888 176 }
duke@435 177 };
duke@435 178
duke@435 179 class TraceMemoryManagerStats : public StackObj {
duke@435 180 private:
duke@435 181 bool _fullGC;
kevinw@2058 182 bool _recordGCBeginTime;
kevinw@2058 183 bool _recordPreGCUsage;
kevinw@2058 184 bool _recordPeakUsage;
kevinw@2058 185 bool _recordPostGCUsage;
kevinw@2058 186 bool _recordAccumulatedGCTime;
kevinw@2058 187 bool _recordGCEndTime;
kevinw@2058 188 bool _countCollection;
fparain@2888 189 GCCause::Cause _cause;
duke@435 190 public:
kevinw@2058 191 TraceMemoryManagerStats() {}
kevinw@2058 192 TraceMemoryManagerStats(bool fullGC,
fparain@2888 193 GCCause::Cause cause,
kevinw@2058 194 bool recordGCBeginTime = true,
kevinw@2058 195 bool recordPreGCUsage = true,
kevinw@2058 196 bool recordPeakUsage = true,
kevinw@2058 197 bool recordPostGCUsage = true,
kevinw@2058 198 bool recordAccumulatedGCTime = true,
kevinw@2058 199 bool recordGCEndTime = true,
kevinw@2058 200 bool countCollection = true);
kevinw@2058 201
kevinw@2058 202 void initialize(bool fullGC,
fparain@2888 203 GCCause::Cause cause,
kevinw@2058 204 bool recordGCBeginTime,
kevinw@2058 205 bool recordPreGCUsage,
kevinw@2058 206 bool recordPeakUsage,
kevinw@2058 207 bool recordPostGCUsage,
kevinw@2058 208 bool recordAccumulatedGCTime,
kevinw@2058 209 bool recordGCEndTime,
kevinw@2058 210 bool countCollection);
kevinw@2058 211
fparain@2888 212 TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause);
duke@435 213 ~TraceMemoryManagerStats();
duke@435 214 };
stefank@2314 215
stefank@2314 216 #endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP

mercurial