src/share/vm/services/memoryManager.hpp

Print this page
rev 4210 : 8000754: NPG: Implement a MemoryPool MXBean for Metaspace


  39 class MemoryPool;
  40 class GCMemoryManager;
  41 class OopClosure;
  42 
  43 class MemoryManager : public CHeapObj<mtInternal> {
  44 private:
  45   enum {
  46     max_num_pools = 10
  47   };
  48 
  49   MemoryPool* _pools[max_num_pools];
  50   int         _num_pools;
  51 
  52 protected:
  53   volatile instanceOop _memory_mgr_obj;
  54 
  55 public:
  56   enum Name {
  57     Abstract,
  58     CodeCache,

  59     Copy,
  60     MarkSweepCompact,
  61     ParNew,
  62     ConcurrentMarkSweep,
  63     PSScavenge,
  64     PSMarkSweep,
  65     G1YoungGen,
  66     G1OldGen
  67   };
  68 
  69   MemoryManager();
  70 
  71   int num_memory_pools() const           { return _num_pools; }
  72   MemoryPool* get_memory_pool(int index) {
  73     assert(index >= 0 && index < _num_pools, "Invalid index");
  74     return _pools[index];
  75   }
  76 
  77   void add_pool(MemoryPool* pool);
  78 
  79   bool is_manager(instanceHandle mh)     { return mh() == _memory_mgr_obj; }
  80 
  81   virtual instanceOop get_memory_manager_instance(TRAPS);
  82   virtual MemoryManager::Name kind()     { return MemoryManager::Abstract; }
  83   virtual bool is_gc_memory_manager()    { return false; }
  84   virtual const char* name() = 0;
  85 
  86   // GC support
  87   void oops_do(OopClosure* f);
  88 
  89   // Static factory methods to get a memory manager of a specific type
  90   static MemoryManager*   get_code_cache_memory_manager();

  91   static GCMemoryManager* get_copy_memory_manager();
  92   static GCMemoryManager* get_msc_memory_manager();
  93   static GCMemoryManager* get_parnew_memory_manager();
  94   static GCMemoryManager* get_cms_memory_manager();
  95   static GCMemoryManager* get_psScavenge_memory_manager();
  96   static GCMemoryManager* get_psMarkSweep_memory_manager();
  97   static GCMemoryManager* get_g1YoungGen_memory_manager();
  98   static GCMemoryManager* get_g1OldGen_memory_manager();
  99 
 100 };
 101 
 102 class CodeCacheMemoryManager : public MemoryManager {
 103 private:
 104 public:
 105   CodeCacheMemoryManager() : MemoryManager() {}
 106 
 107   MemoryManager::Name kind() { return MemoryManager::CodeCache; }
 108   const char* name()         { return "CodeCacheManager"; }








 109 };
 110 
 111 class GCStatInfo : public ResourceObj {
 112 private:
 113   size_t _index;
 114   jlong  _start_time;
 115   jlong  _end_time;
 116 
 117   // We keep memory usage of all memory pools
 118   MemoryUsage* _before_gc_usage_array;
 119   MemoryUsage* _after_gc_usage_array;
 120   int          _usage_array_size;
 121 
 122   void set_gc_usage(int pool_index, MemoryUsage, bool before_gc);
 123 
 124 public:
 125   GCStatInfo(int num_pools);
 126   ~GCStatInfo();
 127 
 128   size_t gc_index()               { return _index; }




  39 class MemoryPool;
  40 class GCMemoryManager;
  41 class OopClosure;
  42 
  43 class MemoryManager : public CHeapObj<mtInternal> {
  44 private:
  45   enum {
  46     max_num_pools = 10
  47   };
  48 
  49   MemoryPool* _pools[max_num_pools];
  50   int         _num_pools;
  51 
  52 protected:
  53   volatile instanceOop _memory_mgr_obj;
  54 
  55 public:
  56   enum Name {
  57     Abstract,
  58     CodeCache,
  59     Metaspace,
  60     Copy,
  61     MarkSweepCompact,
  62     ParNew,
  63     ConcurrentMarkSweep,
  64     PSScavenge,
  65     PSMarkSweep,
  66     G1YoungGen,
  67     G1OldGen
  68   };
  69 
  70   MemoryManager();
  71 
  72   int num_memory_pools() const           { return _num_pools; }
  73   MemoryPool* get_memory_pool(int index) {
  74     assert(index >= 0 && index < _num_pools, "Invalid index");
  75     return _pools[index];
  76   }
  77 
  78   void add_pool(MemoryPool* pool);
  79 
  80   bool is_manager(instanceHandle mh)     { return mh() == _memory_mgr_obj; }
  81 
  82   virtual instanceOop get_memory_manager_instance(TRAPS);
  83   virtual MemoryManager::Name kind()     { return MemoryManager::Abstract; }
  84   virtual bool is_gc_memory_manager()    { return false; }
  85   virtual const char* name() = 0;
  86 
  87   // GC support
  88   void oops_do(OopClosure* f);
  89 
  90   // Static factory methods to get a memory manager of a specific type
  91   static MemoryManager*   get_code_cache_memory_manager();
  92   static MemoryManager*   get_metaspace_memory_manager();
  93   static GCMemoryManager* get_copy_memory_manager();
  94   static GCMemoryManager* get_msc_memory_manager();
  95   static GCMemoryManager* get_parnew_memory_manager();
  96   static GCMemoryManager* get_cms_memory_manager();
  97   static GCMemoryManager* get_psScavenge_memory_manager();
  98   static GCMemoryManager* get_psMarkSweep_memory_manager();
  99   static GCMemoryManager* get_g1YoungGen_memory_manager();
 100   static GCMemoryManager* get_g1OldGen_memory_manager();
 101 
 102 };
 103 
 104 class CodeCacheMemoryManager : public MemoryManager {
 105 private:
 106 public:
 107   CodeCacheMemoryManager() : MemoryManager() {}
 108 
 109   MemoryManager::Name kind() { return MemoryManager::CodeCache; }
 110   const char* name()         { return "CodeCacheManager"; }
 111 };
 112 
 113 class MetaspaceMemoryManager : public MemoryManager {
 114 public:
 115   MetaspaceMemoryManager() : MemoryManager() {}
 116 
 117   MemoryManager::Name kind() { return MemoryManager::Metaspace; }
 118   const char *name()         { return "MetaspaceManager"; }
 119 };
 120 
 121 class GCStatInfo : public ResourceObj {
 122 private:
 123   size_t _index;
 124   jlong  _start_time;
 125   jlong  _end_time;
 126 
 127   // We keep memory usage of all memory pools
 128   MemoryUsage* _before_gc_usage_array;
 129   MemoryUsage* _after_gc_usage_array;
 130   int          _usage_array_size;
 131 
 132   void set_gc_usage(int pool_index, MemoryUsage, bool before_gc);
 133 
 134 public:
 135   GCStatInfo(int num_pools);
 136   ~GCStatInfo();
 137 
 138   size_t gc_index()               { return _index; }