< prev index next >

src/hotspot/share/services/memoryPool.cpp

Print this page
rev 47957 : 8191564: Refactor GC related servicability code into GC specific subclasses


  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "gc/serial/defNewGeneration.hpp"
  29 #include "gc/shared/space.hpp"
  30 #include "memory/metaspace.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/javaCalls.hpp"
  34 #include "runtime/orderAccess.inline.hpp"
  35 #include "services/lowMemoryDetector.hpp"
  36 #include "services/management.hpp"
  37 #include "services/memoryManager.hpp"
  38 #include "services/memoryPool.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 #include "utilities/macros.hpp"
  41 #if INCLUDE_ALL_GCS
  42 #include "gc/cms/compactibleFreeListSpace.hpp"
  43 #endif
  44 
  45 MemoryPool::MemoryPool(const char* name,
  46                        PoolType type,
  47                        size_t init_size,
  48                        size_t max_size,
  49                        bool support_usage_threshold,
  50                        bool support_gc_threshold) {
  51   _name = name;
  52   _initial_size = init_size;
  53   _max_size = max_size;
  54   (void)const_cast<instanceOop&>(_memory_pool_obj = instanceOop(NULL));
  55   _available_for_allocation = true;
  56   _num_managers = 0;
  57   _type = type;
  58 
  59   // initialize the max and init size of collection usage
  60   _after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
  61 
  62   _usage_sensor = NULL;
  63   _gc_usage_sensor = NULL;


 210                                                          bool support_usage_threshold) :
 211   CollectedMemoryPool(name, type, young_gen->from()->capacity(), max_size,
 212                       support_usage_threshold), _young_gen(young_gen) {
 213 }
 214 
 215 size_t SurvivorContiguousSpacePool::used_in_bytes() {
 216   return _young_gen->from()->used();
 217 }
 218 
 219 size_t SurvivorContiguousSpacePool::committed_in_bytes() {
 220   return _young_gen->from()->capacity();
 221 }
 222 
 223 MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
 224   size_t maxSize = (available_for_allocation() ? max_size() : 0);
 225   size_t used    = used_in_bytes();
 226   size_t committed = committed_in_bytes();
 227 
 228   return MemoryUsage(initial_size(), used, committed, maxSize);
 229 }
 230 
 231 #if INCLUDE_ALL_GCS
 232 CompactibleFreeListSpacePool::CompactibleFreeListSpacePool(CompactibleFreeListSpace* space,
 233                                                            const char* name,
 234                                                            PoolType type,
 235                                                            size_t max_size,
 236                                                            bool support_usage_threshold) :
 237   CollectedMemoryPool(name, type, space->capacity(), max_size,
 238                       support_usage_threshold), _space(space) {
 239 }
 240 
 241 size_t CompactibleFreeListSpacePool::used_in_bytes() {
 242   return _space->used();
 243 }
 244 
 245 MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() {
 246   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 247   size_t used      = used_in_bytes();
 248   size_t committed = _space->capacity();
 249 
 250   return MemoryUsage(initial_size(), used, committed, maxSize);
 251 }
 252 #endif // INCLUDE_ALL_GCS
 253 
 254 GenerationPool::GenerationPool(Generation* gen,
 255                                const char* name,
 256                                PoolType type,
 257                                bool support_usage_threshold) :
 258   CollectedMemoryPool(name, type, gen->capacity(), gen->max_capacity(),
 259                       support_usage_threshold), _gen(gen) {
 260 }
 261 
 262 size_t GenerationPool::used_in_bytes() {
 263   return _gen->used();
 264 }
 265 
 266 MemoryUsage GenerationPool::get_memory_usage() {
 267   size_t used      = used_in_bytes();
 268   size_t committed = _gen->capacity();
 269   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 270 
 271   return MemoryUsage(initial_size(), used, committed, maxSize);
 272 }




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "gc/serial/defNewGeneration.hpp"
  29 #include "gc/shared/space.hpp"
  30 #include "memory/metaspace.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/javaCalls.hpp"
  34 #include "runtime/orderAccess.inline.hpp"
  35 #include "services/lowMemoryDetector.hpp"
  36 #include "services/management.hpp"
  37 #include "services/memoryManager.hpp"
  38 #include "services/memoryPool.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 #include "utilities/macros.hpp"



  41 
  42 MemoryPool::MemoryPool(const char* name,
  43                        PoolType type,
  44                        size_t init_size,
  45                        size_t max_size,
  46                        bool support_usage_threshold,
  47                        bool support_gc_threshold) {
  48   _name = name;
  49   _initial_size = init_size;
  50   _max_size = max_size;
  51   (void)const_cast<instanceOop&>(_memory_pool_obj = instanceOop(NULL));
  52   _available_for_allocation = true;
  53   _num_managers = 0;
  54   _type = type;
  55 
  56   // initialize the max and init size of collection usage
  57   _after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
  58 
  59   _usage_sensor = NULL;
  60   _gc_usage_sensor = NULL;


 207                                                          bool support_usage_threshold) :
 208   CollectedMemoryPool(name, type, young_gen->from()->capacity(), max_size,
 209                       support_usage_threshold), _young_gen(young_gen) {
 210 }
 211 
 212 size_t SurvivorContiguousSpacePool::used_in_bytes() {
 213   return _young_gen->from()->used();
 214 }
 215 
 216 size_t SurvivorContiguousSpacePool::committed_in_bytes() {
 217   return _young_gen->from()->capacity();
 218 }
 219 
 220 MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
 221   size_t maxSize = (available_for_allocation() ? max_size() : 0);
 222   size_t used    = used_in_bytes();
 223   size_t committed = committed_in_bytes();
 224 
 225   return MemoryUsage(initial_size(), used, committed, maxSize);
 226 }























 227 
 228 GenerationPool::GenerationPool(Generation* gen,
 229                                const char* name,
 230                                PoolType type,
 231                                bool support_usage_threshold) :
 232   CollectedMemoryPool(name, type, gen->capacity(), gen->max_capacity(),
 233                       support_usage_threshold), _gen(gen) {
 234 }
 235 
 236 size_t GenerationPool::used_in_bytes() {
 237   return _gen->used();
 238 }
 239 
 240 MemoryUsage GenerationPool::get_memory_usage() {
 241   size_t used      = used_in_bytes();
 242   size_t committed = _gen->capacity();
 243   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 244 
 245   return MemoryUsage(initial_size(), used, committed, maxSize);
 246 }


< prev index next >