src/share/vm/services/memoryService.hpp

Fri, 01 Feb 2013 23:48:08 +0100

author
ctornqvi
date
Fri, 01 Feb 2013 23:48:08 +0100
changeset 4512
4102b59539ce
parent 4037
da91efe96a93
child 4825
dbd5837b342f
permissions
-rw-r--r--

8005012: Add WB APIs to better support NMT testing
Summary: Add WB API functions to enable better NMT testing
Reviewed-by: dholmes, zgu

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
duke@435 76 static void add_generation_memory_pool(Generation* gen,
duke@435 77 MemoryManager* major_mgr,
duke@435 78 MemoryManager* minor_mgr);
duke@435 79 static void add_generation_memory_pool(Generation* gen,
duke@435 80 MemoryManager* major_mgr) {
duke@435 81 add_generation_memory_pool(gen, major_mgr, NULL);
duke@435 82 }
duke@435 83
duke@435 84
duke@435 85 static void add_psYoung_memory_pool(PSYoungGen* gen,
duke@435 86 MemoryManager* major_mgr,
duke@435 87 MemoryManager* minor_mgr);
duke@435 88 static void add_psOld_memory_pool(PSOldGen* gen,
duke@435 89 MemoryManager* mgr);
duke@435 90
tonyp@1524 91 static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 92 MemoryManager* major_mgr,
tonyp@1524 93 MemoryManager* minor_mgr);
tonyp@1524 94 static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 95 MemoryManager* mgr);
duke@435 96
duke@435 97 static MemoryPool* add_space(ContiguousSpace* space,
duke@435 98 const char* name,
duke@435 99 bool is_heap,
duke@435 100 size_t max_size,
duke@435 101 bool support_usage_threshold);
duke@435 102 static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
duke@435 103 const char* name,
duke@435 104 bool is_heap,
duke@435 105 size_t max_size,
duke@435 106 bool support_usage_threshold);
duke@435 107 static MemoryPool* add_gen(Generation* gen,
duke@435 108 const char* name,
duke@435 109 bool is_heap,
duke@435 110 bool support_usage_threshold);
duke@435 111 static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
duke@435 112 const char* name,
duke@435 113 bool is_heap,
duke@435 114 size_t max_size,
duke@435 115 bool support_usage_threshold);
duke@435 116
duke@435 117 static void add_gen_collected_heap_info(GenCollectedHeap* heap);
duke@435 118 static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
tonyp@1524 119 static void add_g1_heap_info(G1CollectedHeap* g1h);
duke@435 120
duke@435 121 public:
duke@435 122 static void set_universe_heap(CollectedHeap* heap);
duke@435 123 static void add_code_heap_memory_pool(CodeHeap* heap);
duke@435 124
duke@435 125 static MemoryPool* get_memory_pool(instanceHandle pool);
duke@435 126 static MemoryManager* get_memory_manager(instanceHandle mgr);
duke@435 127
duke@435 128 static const int num_memory_pools() {
duke@435 129 return _pools_list->length();
duke@435 130 }
duke@435 131 static const int num_memory_managers() {
duke@435 132 return _managers_list->length();
duke@435 133 }
duke@435 134
duke@435 135 static MemoryPool* get_memory_pool(int index) {
duke@435 136 return _pools_list->at(index);
duke@435 137 }
duke@435 138
duke@435 139 static MemoryManager* get_memory_manager(int index) {
duke@435 140 return _managers_list->at(index);
duke@435 141 }
duke@435 142
duke@435 143 static void track_memory_usage();
duke@435 144 static void track_code_cache_memory_usage() {
duke@435 145 track_memory_pool_usage(_code_heap_pool);
duke@435 146 }
duke@435 147 static void track_memory_pool_usage(MemoryPool* pool);
duke@435 148
kevinw@2058 149 static void gc_begin(bool fullGC, bool recordGCBeginTime,
kevinw@2058 150 bool recordAccumulatedGCTime,
kevinw@2058 151 bool recordPreGCUsage, bool recordPeakUsage);
kevinw@2058 152 static void gc_end(bool fullGC, bool recordPostGCUsage,
kevinw@2058 153 bool recordAccumulatedGCTime,
fparain@2888 154 bool recordGCEndTime, bool countCollection,
fparain@2888 155 GCCause::Cause cause);
kevinw@2058 156
duke@435 157
duke@435 158 static void oops_do(OopClosure* f);
duke@435 159
duke@435 160 static bool get_verbose() { return PrintGC; }
duke@435 161 static bool set_verbose(bool verbose);
duke@435 162
duke@435 163 // Create an instance of java/lang/management/MemoryUsage
duke@435 164 static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
fparain@2888 165
fparain@2888 166 static const GCMemoryManager* get_minor_gc_manager() {
fparain@2888 167 return _minor_gc_manager;
fparain@2888 168 }
fparain@2888 169
fparain@2888 170 static const GCMemoryManager* get_major_gc_manager() {
fparain@2888 171 return _major_gc_manager;
fparain@2888 172 }
duke@435 173 };
duke@435 174
duke@435 175 class TraceMemoryManagerStats : public StackObj {
duke@435 176 private:
duke@435 177 bool _fullGC;
kevinw@2058 178 bool _recordGCBeginTime;
kevinw@2058 179 bool _recordPreGCUsage;
kevinw@2058 180 bool _recordPeakUsage;
kevinw@2058 181 bool _recordPostGCUsage;
kevinw@2058 182 bool _recordAccumulatedGCTime;
kevinw@2058 183 bool _recordGCEndTime;
kevinw@2058 184 bool _countCollection;
fparain@2888 185 GCCause::Cause _cause;
duke@435 186 public:
kevinw@2058 187 TraceMemoryManagerStats() {}
kevinw@2058 188 TraceMemoryManagerStats(bool fullGC,
fparain@2888 189 GCCause::Cause cause,
kevinw@2058 190 bool recordGCBeginTime = true,
kevinw@2058 191 bool recordPreGCUsage = true,
kevinw@2058 192 bool recordPeakUsage = true,
kevinw@2058 193 bool recordPostGCUsage = true,
kevinw@2058 194 bool recordAccumulatedGCTime = true,
kevinw@2058 195 bool recordGCEndTime = true,
kevinw@2058 196 bool countCollection = true);
kevinw@2058 197
kevinw@2058 198 void initialize(bool fullGC,
fparain@2888 199 GCCause::Cause cause,
kevinw@2058 200 bool recordGCBeginTime,
kevinw@2058 201 bool recordPreGCUsage,
kevinw@2058 202 bool recordPeakUsage,
kevinw@2058 203 bool recordPostGCUsage,
kevinw@2058 204 bool recordAccumulatedGCTime,
kevinw@2058 205 bool recordGCEndTime,
kevinw@2058 206 bool countCollection);
kevinw@2058 207
fparain@2888 208 TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause);
duke@435 209 ~TraceMemoryManagerStats();
duke@435 210 };
stefank@2314 211
stefank@2314 212 #endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP

mercurial