src/share/vm/services/memoryService.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial