< prev index next >

src/share/vm/services/memoryManager.hpp

Print this page
rev 12854 : [mq]: gcinterface.patch


   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_SERVICES_MEMORYMANAGER_HPP
  26 #define SHARE_VM_SERVICES_MEMORYMANAGER_HPP
  27 

  28 #include "memory/allocation.hpp"

  29 #include "runtime/timer.hpp"

  30 #include "services/memoryUsage.hpp"
  31 
  32 // A memory manager is responsible for managing one or more memory pools.
  33 // The garbage collector is one type of memory managers responsible
  34 // for reclaiming memory occupied by unreachable objects.  A Java virtual
  35 // machine may have one or more memory managers.   It may
  36 // add or remove memory managers during execution.
  37 // A memory pool can be managed by more than one memory managers.
  38 
  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];


  58   int num_memory_pools() const           { return _num_pools; }
  59   MemoryPool* get_memory_pool(int index) {
  60     assert(index >= 0 && index < _num_pools, "Invalid index");
  61     return _pools[index];
  62   }
  63 
  64   void add_pool(MemoryPool* pool);
  65 
  66   bool is_manager(instanceHandle mh)     { return mh() == _memory_mgr_obj; }
  67 
  68   virtual instanceOop get_memory_manager_instance(TRAPS);
  69   virtual bool is_gc_memory_manager()    { return false; }
  70   virtual const char* name() = 0;
  71 
  72   // GC support
  73   void oops_do(OopClosure* f);
  74 
  75   // Static factory methods to get a memory manager of a specific type
  76   static MemoryManager*   get_code_cache_memory_manager();
  77   static MemoryManager*   get_metaspace_memory_manager();
  78   static GCMemoryManager* get_copy_memory_manager();
  79   static GCMemoryManager* get_msc_memory_manager();
  80   static GCMemoryManager* get_parnew_memory_manager();
  81   static GCMemoryManager* get_cms_memory_manager();
  82   static GCMemoryManager* get_psScavenge_memory_manager();
  83   static GCMemoryManager* get_psMarkSweep_memory_manager();
  84   static GCMemoryManager* get_g1YoungGen_memory_manager();
  85   static GCMemoryManager* get_g1OldGen_memory_manager();
  86 };
  87 
  88 class CodeCacheMemoryManager : public MemoryManager {
  89 private:
  90 public:
  91   CodeCacheMemoryManager() : MemoryManager() {}
  92 
  93   const char* name() { return "CodeCacheManager"; }
  94 };
  95 
  96 class MetaspaceMemoryManager : public MemoryManager {
  97 public:
  98   MetaspaceMemoryManager() : MemoryManager() {}
  99 
 100   const char* name() { return "Metaspace Manager"; }
 101 };
 102 
 103 class GCStatInfo : public ResourceObj {
 104 private:
 105   size_t _index;


 167 
 168   bool   is_gc_memory_manager()         { return true; }
 169   jlong  gc_time_ms()                   { return _accumulated_timer.milliseconds(); }
 170   size_t gc_count()                     { return _num_collections; }
 171   int    num_gc_threads()               { return _num_gc_threads; }
 172   void   set_num_gc_threads(int count)  { _num_gc_threads = count; }
 173 
 174   void   gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
 175                   bool recordAccumulatedGCTime);
 176   void   gc_end(bool recordPostGCUsage, bool recordAccumulatedGCTime,
 177                 bool recordGCEndTime, bool countCollection, GCCause::Cause cause);
 178 
 179   void        reset_gc_stat()   { _num_collections = 0; _accumulated_timer.reset(); }
 180 
 181   // Copy out _last_gc_stat to the given destination, returning
 182   // the collection count. Zero signifies no gc has taken place.
 183   size_t get_last_gc_stat(GCStatInfo* dest);
 184 
 185   void set_notification_enabled(bool enabled) { _notification_enabled = enabled; }
 186   bool is_notification_enabled() { return _notification_enabled; }
 187 };
 188 
 189 // These subclasses of GCMemoryManager are defined to include
 190 // GC-specific information.
 191 // TODO: Add GC-specific information
 192 class CopyMemoryManager : public GCMemoryManager {
 193 private:
 194 public:
 195   CopyMemoryManager() : GCMemoryManager() {}
 196 
 197   const char* name() { return "Copy"; }
 198 };
 199 
 200 class MSCMemoryManager : public GCMemoryManager {
 201 private:
 202 public:
 203   MSCMemoryManager() : GCMemoryManager() {}
 204 
 205   const char* name() { return "MarkSweepCompact"; }
 206 };
 207 
 208 class ParNewMemoryManager : public GCMemoryManager {
 209 private:
 210 public:
 211   ParNewMemoryManager() : GCMemoryManager() {}
 212 
 213   const char* name() { return "ParNew"; }
 214 };
 215 
 216 class CMSMemoryManager : public GCMemoryManager {
 217 private:
 218 public:
 219   CMSMemoryManager() : GCMemoryManager() {}
 220 
 221   const char* name() { return "ConcurrentMarkSweep";}
 222 };
 223 
 224 class PSScavengeMemoryManager : public GCMemoryManager {
 225 private:
 226 public:
 227   PSScavengeMemoryManager() : GCMemoryManager() {}
 228 
 229   const char* name() { return "PS Scavenge"; }
 230 };
 231 
 232 class PSMarkSweepMemoryManager : public GCMemoryManager {
 233 private:
 234 public:
 235   PSMarkSweepMemoryManager() : GCMemoryManager() {}
 236 
 237   const char* name() { return "PS MarkSweep"; }
 238 };
 239 
 240 class G1YoungGenMemoryManager : public GCMemoryManager {
 241 private:
 242 public:
 243   G1YoungGenMemoryManager() : GCMemoryManager() {}
 244 
 245   const char* name() { return "G1 Young Generation"; }
 246 };
 247 
 248 class G1OldGenMemoryManager : public GCMemoryManager {
 249 private:
 250 public:
 251   G1OldGenMemoryManager() : GCMemoryManager() {}
 252 
 253   const char* name() { return "G1 Old Generation"; }
 254 };
 255 
 256 #endif // SHARE_VM_SERVICES_MEMORYMANAGER_HPP


   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_SERVICES_MEMORYMANAGER_HPP
  26 #define SHARE_VM_SERVICES_MEMORYMANAGER_HPP
  27 
  28 #include "gc/shared/gcCause.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "runtime/timer.hpp"
  32 #include "oops/instanceOop.hpp"
  33 #include "services/memoryUsage.hpp"
  34 
  35 // A memory manager is responsible for managing one or more memory pools.
  36 // The garbage collector is one type of memory managers responsible
  37 // for reclaiming memory occupied by unreachable objects.  A Java virtual
  38 // machine may have one or more memory managers.   It may
  39 // add or remove memory managers during execution.
  40 // A memory pool can be managed by more than one memory managers.
  41 
  42 class MemoryPool;
  43 class GCMemoryManager;
  44 class OopClosure;
  45 
  46 class MemoryManager : public CHeapObj<mtInternal> {
  47 private:
  48   enum {
  49     max_num_pools = 10
  50   };
  51 
  52   MemoryPool* _pools[max_num_pools];


  61   int num_memory_pools() const           { return _num_pools; }
  62   MemoryPool* get_memory_pool(int index) {
  63     assert(index >= 0 && index < _num_pools, "Invalid index");
  64     return _pools[index];
  65   }
  66 
  67   void add_pool(MemoryPool* pool);
  68 
  69   bool is_manager(instanceHandle mh)     { return mh() == _memory_mgr_obj; }
  70 
  71   virtual instanceOop get_memory_manager_instance(TRAPS);
  72   virtual bool is_gc_memory_manager()    { return false; }
  73   virtual const char* name() = 0;
  74 
  75   // GC support
  76   void oops_do(OopClosure* f);
  77 
  78   // Static factory methods to get a memory manager of a specific type
  79   static MemoryManager*   get_code_cache_memory_manager();
  80   static MemoryManager*   get_metaspace_memory_manager();








  81 };
  82 
  83 class CodeCacheMemoryManager : public MemoryManager {
  84 private:
  85 public:
  86   CodeCacheMemoryManager() : MemoryManager() {}
  87 
  88   const char* name() { return "CodeCacheManager"; }
  89 };
  90 
  91 class MetaspaceMemoryManager : public MemoryManager {
  92 public:
  93   MetaspaceMemoryManager() : MemoryManager() {}
  94 
  95   const char* name() { return "Metaspace Manager"; }
  96 };
  97 
  98 class GCStatInfo : public ResourceObj {
  99 private:
 100   size_t _index;


 162 
 163   bool   is_gc_memory_manager()         { return true; }
 164   jlong  gc_time_ms()                   { return _accumulated_timer.milliseconds(); }
 165   size_t gc_count()                     { return _num_collections; }
 166   int    num_gc_threads()               { return _num_gc_threads; }
 167   void   set_num_gc_threads(int count)  { _num_gc_threads = count; }
 168 
 169   void   gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
 170                   bool recordAccumulatedGCTime);
 171   void   gc_end(bool recordPostGCUsage, bool recordAccumulatedGCTime,
 172                 bool recordGCEndTime, bool countCollection, GCCause::Cause cause);
 173 
 174   void        reset_gc_stat()   { _num_collections = 0; _accumulated_timer.reset(); }
 175 
 176   // Copy out _last_gc_stat to the given destination, returning
 177   // the collection count. Zero signifies no gc has taken place.
 178   size_t get_last_gc_stat(GCStatInfo* dest);
 179 
 180   void set_notification_enabled(bool enabled) { _notification_enabled = enabled; }
 181   bool is_notification_enabled() { return _notification_enabled; }



































































 182 };
 183 
 184 #endif // SHARE_VM_SERVICES_MEMORYMANAGER_HPP
< prev index next >