< prev index next >

src/share/vm/services/memoryService.hpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  60   enum {
  61     minor = 0,
  62     major = 1,
  63     n_gens = 2
  64   };
  65 
  66   static GrowableArray<MemoryPool*>*    _pools_list;
  67   static GrowableArray<MemoryManager*>* _managers_list;
  68 
  69   // memory managers for minor and major GC statistics
  70   static GCMemoryManager*               _major_gc_manager;
  71   static GCMemoryManager*               _minor_gc_manager;
  72 
  73   // Code heap memory pool
  74   static MemoryPool*                    _code_heap_pool;
  75 
  76   static MemoryPool*                    _metaspace_pool;
  77   static MemoryPool*                    _compressed_class_pool;
  78 
  79   static void add_generation_memory_pool(Generation* gen,
  80                                          MemoryManager* major_mgr,
  81                                          MemoryManager* minor_mgr);
  82   static void add_generation_memory_pool(Generation* gen,
  83                                          MemoryManager* major_mgr) {
  84     add_generation_memory_pool(gen, major_mgr, NULL);
  85   }
  86 
  87 
  88   static void add_psYoung_memory_pool(PSYoungGen* gen,
  89                                       MemoryManager* major_mgr,
  90                                       MemoryManager* minor_mgr);
  91   static void add_psOld_memory_pool(PSOldGen* gen,
  92                                     MemoryManager* mgr);
  93 
  94   static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
  95                                          MemoryManager* major_mgr,
  96                                          MemoryManager* minor_mgr);
  97   static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
  98                                        MemoryManager* mgr);

  99 
 100   static MemoryPool* add_space(ContiguousSpace* space,
 101                                const char* name,
 102                                bool is_heap,
 103                                size_t max_size,
 104                                bool support_usage_threshold);
 105   static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
 106                                          const char* name,
 107                                          bool is_heap,
 108                                          size_t max_size,
 109                                          bool support_usage_threshold);
 110   static MemoryPool* add_gen(Generation* gen,
 111                              const char* name,
 112                              bool is_heap,
 113                              bool support_usage_threshold);
 114   static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
 115                                    const char* name,
 116                                    bool is_heap,
 117                                    size_t max_size,
 118                                    bool support_usage_threshold);


 145   }
 146 
 147   static void track_memory_usage();
 148   static void track_code_cache_memory_usage() {
 149     track_memory_pool_usage(_code_heap_pool);
 150   }
 151   static void track_metaspace_memory_usage() {
 152     track_memory_pool_usage(_metaspace_pool);
 153   }
 154   static void track_compressed_class_memory_usage() {
 155     track_memory_pool_usage(_compressed_class_pool);
 156   }
 157   static void track_memory_pool_usage(MemoryPool* pool);
 158 
 159   static void gc_begin(bool fullGC, bool recordGCBeginTime,
 160                        bool recordAccumulatedGCTime,
 161                        bool recordPreGCUsage, bool recordPeakUsage);
 162   static void gc_end(bool fullGC, bool recordPostGCUsage,
 163                      bool recordAccumulatedGCTime,
 164                      bool recordGCEndTime, bool countCollection,
 165                      GCCause::Cause cause);

 166 
 167 
 168   static void oops_do(OopClosure* f);
 169 
 170   static bool get_verbose() { return PrintGC; }
 171   static bool set_verbose(bool verbose);
 172 
 173   // Create an instance of java/lang/management/MemoryUsage
 174   static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
 175 
 176   static const GCMemoryManager* get_minor_gc_manager() {
 177       return _minor_gc_manager;
 178   }
 179 
 180   static const GCMemoryManager* get_major_gc_manager() {
 181       return _major_gc_manager;
 182   }
 183 };
 184 
 185 class TraceMemoryManagerStats : public StackObj {
 186 private:
 187   bool         _fullGC;

 188   bool         _recordGCBeginTime;
 189   bool         _recordPreGCUsage;
 190   bool         _recordPeakUsage;
 191   bool         _recordPostGCUsage;
 192   bool         _recordAccumulatedGCTime;
 193   bool         _recordGCEndTime;
 194   bool         _countCollection;
 195   GCCause::Cause _cause;
 196 public:
 197   TraceMemoryManagerStats() {}
 198   TraceMemoryManagerStats(bool fullGC,
 199                           GCCause::Cause cause,

 200                           bool recordGCBeginTime = true,
 201                           bool recordPreGCUsage = true,
 202                           bool recordPeakUsage = true,
 203                           bool recordPostGCUsage = true,
 204                           bool recordAccumulatedGCTime = true,
 205                           bool recordGCEndTime = true,
 206                           bool countCollection = true);
 207 
 208   void initialize(bool fullGC,
 209                   GCCause::Cause cause,

 210                   bool recordGCBeginTime,
 211                   bool recordPreGCUsage,
 212                   bool recordPeakUsage,
 213                   bool recordPostGCUsage,
 214                   bool recordAccumulatedGCTime,
 215                   bool recordGCEndTime,
 216                   bool countCollection);
 217 
 218   TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause);
 219   ~TraceMemoryManagerStats();
 220 };
 221 
 222 #endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP
   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  60   enum {
  61     minor = 0,
  62     major = 1,
  63     n_gens = 2
  64   };
  65 
  66   static GrowableArray<MemoryPool*>*    _pools_list;
  67   static GrowableArray<MemoryManager*>* _managers_list;
  68 
  69   // memory managers for minor and major GC statistics
  70   static GCMemoryManager*               _major_gc_manager;
  71   static GCMemoryManager*               _minor_gc_manager;
  72 
  73   // Code heap memory pool
  74   static MemoryPool*                    _code_heap_pool;
  75 
  76   static MemoryPool*                    _metaspace_pool;
  77   static MemoryPool*                    _compressed_class_pool;
  78 
  79   static void add_generation_memory_pool(Generation* gen,
  80                                          GCMemoryManager* major_mgr,
  81                                          GCMemoryManager* minor_mgr);
  82   static void add_generation_memory_pool(Generation* gen,
  83                                          GCMemoryManager* major_mgr) {
  84     add_generation_memory_pool(gen, major_mgr, NULL);
  85   }
  86 
  87 
  88   static void add_psYoung_memory_pool(PSYoungGen* gen,
  89                                       GCMemoryManager* major_mgr,
  90                                       GCMemoryManager* minor_mgr);
  91   static void add_psOld_memory_pool(PSOldGen* gen,
  92                                     GCMemoryManager* mgr);
  93 
  94   static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
  95                                          GCMemoryManager* major_mgr,
  96                                          GCMemoryManager* minor_mgr);
  97   static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
  98                                        GCMemoryManager* major_mgr,
  99                                        GCMemoryManager* minor_mgr);
 100 
 101   static MemoryPool* add_space(ContiguousSpace* space,
 102                                const char* name,
 103                                bool is_heap,
 104                                size_t max_size,
 105                                bool support_usage_threshold);
 106   static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
 107                                          const char* name,
 108                                          bool is_heap,
 109                                          size_t max_size,
 110                                          bool support_usage_threshold);
 111   static MemoryPool* add_gen(Generation* gen,
 112                              const char* name,
 113                              bool is_heap,
 114                              bool support_usage_threshold);
 115   static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
 116                                    const char* name,
 117                                    bool is_heap,
 118                                    size_t max_size,
 119                                    bool support_usage_threshold);


 146   }
 147 
 148   static void track_memory_usage();
 149   static void track_code_cache_memory_usage() {
 150     track_memory_pool_usage(_code_heap_pool);
 151   }
 152   static void track_metaspace_memory_usage() {
 153     track_memory_pool_usage(_metaspace_pool);
 154   }
 155   static void track_compressed_class_memory_usage() {
 156     track_memory_pool_usage(_compressed_class_pool);
 157   }
 158   static void track_memory_pool_usage(MemoryPool* pool);
 159 
 160   static void gc_begin(bool fullGC, bool recordGCBeginTime,
 161                        bool recordAccumulatedGCTime,
 162                        bool recordPreGCUsage, bool recordPeakUsage);
 163   static void gc_end(bool fullGC, bool recordPostGCUsage,
 164                      bool recordAccumulatedGCTime,
 165                      bool recordGCEndTime, bool countCollection,
 166                      GCCause::Cause cause,
 167                      bool allMemoryPoolsAffected);
 168 
 169 
 170   static void oops_do(OopClosure* f);
 171 
 172   static bool get_verbose() { return PrintGC; }
 173   static bool set_verbose(bool verbose);
 174 
 175   // Create an instance of java/lang/management/MemoryUsage
 176   static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
 177 
 178   static const GCMemoryManager* get_minor_gc_manager() {
 179       return _minor_gc_manager;
 180   }
 181 
 182   static const GCMemoryManager* get_major_gc_manager() {
 183       return _major_gc_manager;
 184   }
 185 };
 186 
 187 class TraceMemoryManagerStats : public StackObj {
 188 private:
 189   bool         _fullGC;
 190   bool         _allMemoryPoolsAffected;
 191   bool         _recordGCBeginTime;
 192   bool         _recordPreGCUsage;
 193   bool         _recordPeakUsage;
 194   bool         _recordPostGCUsage;
 195   bool         _recordAccumulatedGCTime;
 196   bool         _recordGCEndTime;
 197   bool         _countCollection;
 198   GCCause::Cause _cause;
 199 public:
 200   TraceMemoryManagerStats() {}
 201   TraceMemoryManagerStats(bool fullGC,
 202                           GCCause::Cause cause,
 203                           bool allMemoryPoolsAffected = true,
 204                           bool recordGCBeginTime = true,
 205                           bool recordPreGCUsage = true,
 206                           bool recordPeakUsage = true,
 207                           bool recordPostGCUsage = true,
 208                           bool recordAccumulatedGCTime = true,
 209                           bool recordGCEndTime = true,
 210                           bool countCollection = true);
 211 
 212   void initialize(bool fullGC,
 213                   GCCause::Cause cause,
 214                   bool allMemoryPoolsAffected,
 215                   bool recordGCBeginTime,
 216                   bool recordPreGCUsage,
 217                   bool recordPeakUsage,
 218                   bool recordPostGCUsage,
 219                   bool recordAccumulatedGCTime,
 220                   bool recordGCEndTime,
 221                   bool countCollection);
 222 
 223   TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause);
 224   ~TraceMemoryManagerStats();
 225 };
 226 
 227 #endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP
< prev index next >