< prev index next >

src/share/vm/services/memoryService.cpp

Print this page




  29 #include "memory/collectorPolicy.hpp"
  30 #include "memory/defNewGeneration.hpp"
  31 #include "memory/genCollectedHeap.hpp"
  32 #include "memory/generation.hpp"
  33 #include "memory/generationSpec.hpp"
  34 #include "memory/heap.hpp"
  35 #include "memory/memRegion.hpp"
  36 #include "memory/tenuredGeneration.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/globals.hpp"
  39 #include "runtime/javaCalls.hpp"
  40 #include "services/classLoadingService.hpp"
  41 #include "services/lowMemoryDetector.hpp"
  42 #include "services/management.hpp"
  43 #include "services/memoryManager.hpp"
  44 #include "services/memoryPool.hpp"
  45 #include "services/memoryService.hpp"
  46 #include "utilities/growableArray.hpp"
  47 #include "utilities/macros.hpp"
  48 #if INCLUDE_ALL_GCS

  49 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
  50 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  51 #include "gc_implementation/parNew/parNewGeneration.hpp"
  52 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  53 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
  54 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
  55 #include "services/g1MemoryPool.hpp"
  56 #include "services/psMemoryPool.hpp"

  57 #endif // INCLUDE_ALL_GCS
  58 
  59 GrowableArray<MemoryPool*>* MemoryService::_pools_list =
  60   new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_pools_list_size, true);
  61 GrowableArray<MemoryManager*>* MemoryService::_managers_list =
  62   new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryManager*>(init_managers_list_size, true);
  63 
  64 GCMemoryManager* MemoryService::_minor_gc_manager      = NULL;
  65 GCMemoryManager* MemoryService::_major_gc_manager      = NULL;
  66 MemoryPool*      MemoryService::_code_heap_pool        = NULL;
  67 MemoryPool*      MemoryService::_metaspace_pool        = NULL;
  68 MemoryPool*      MemoryService::_compressed_class_pool = NULL;
  69 
  70 class GcThreadCountClosure: public ThreadClosure {
  71  private:
  72   int _count;
  73  public:
  74   GcThreadCountClosure() : _count(0) {};
  75   void do_thread(Thread* thread);
  76   int count() { return _count; }


  79 void GcThreadCountClosure::do_thread(Thread* thread) {
  80   _count++;
  81 }
  82 
  83 void MemoryService::set_universe_heap(CollectedHeap* heap) {
  84   CollectedHeap::Name kind = heap->kind();
  85   switch (kind) {
  86     case CollectedHeap::GenCollectedHeap : {
  87       add_gen_collected_heap_info(GenCollectedHeap::heap());
  88       break;
  89     }
  90 #if INCLUDE_ALL_GCS
  91     case CollectedHeap::ParallelScavengeHeap : {
  92       add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap());
  93       break;
  94     }
  95     case CollectedHeap::G1CollectedHeap : {
  96       add_g1_heap_info(G1CollectedHeap::heap());
  97       break;
  98     }




  99 #endif // INCLUDE_ALL_GCS
 100     default: {
 101       guarantee(false, "Unrecognized kind of heap");
 102     }
 103   }
 104 
 105   // set the GC thread count
 106   GcThreadCountClosure gctcc;
 107   heap->gc_threads_do(&gctcc);
 108   int count = gctcc.count();
 109   if (count > 0) {
 110     _minor_gc_manager->set_num_gc_threads(count);
 111     _major_gc_manager->set_num_gc_threads(count);
 112   }
 113 
 114   // All memory pools and memory managers are initialized.
 115   //
 116   _minor_gc_manager->initialize_gc_stat_info();
 117   _major_gc_manager->initialize_gc_stat_info();
 118 }


 172   _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
 173   _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
 174   _managers_list->append(_minor_gc_manager);
 175   _managers_list->append(_major_gc_manager);
 176 
 177   add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
 178   add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
 179 }
 180 
 181 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
 182   assert(UseG1GC, "sanity");
 183 
 184   _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
 185   _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
 186   _managers_list->append(_minor_gc_manager);
 187   _managers_list->append(_major_gc_manager);
 188 
 189   add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
 190   add_g1OldGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
 191 }


















 192 #endif // INCLUDE_ALL_GCS
 193 
 194 MemoryPool* MemoryService::add_gen(Generation* gen,
 195                                    const char* name,
 196                                    bool is_heap,
 197                                    bool support_usage_threshold) {
 198 
 199   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
 200   GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
 201   _pools_list->append(pool);
 202   return (MemoryPool*) pool;
 203 }
 204 
 205 MemoryPool* MemoryService::add_space(ContiguousSpace* space,
 206                                      const char* name,
 207                                      bool is_heap,
 208                                      size_t max_size,
 209                                      bool support_usage_threshold) {
 210   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
 211   ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold);




  29 #include "memory/collectorPolicy.hpp"
  30 #include "memory/defNewGeneration.hpp"
  31 #include "memory/genCollectedHeap.hpp"
  32 #include "memory/generation.hpp"
  33 #include "memory/generationSpec.hpp"
  34 #include "memory/heap.hpp"
  35 #include "memory/memRegion.hpp"
  36 #include "memory/tenuredGeneration.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/globals.hpp"
  39 #include "runtime/javaCalls.hpp"
  40 #include "services/classLoadingService.hpp"
  41 #include "services/lowMemoryDetector.hpp"
  42 #include "services/management.hpp"
  43 #include "services/memoryManager.hpp"
  44 #include "services/memoryPool.hpp"
  45 #include "services/memoryService.hpp"
  46 #include "utilities/growableArray.hpp"
  47 #include "utilities/macros.hpp"
  48 #if INCLUDE_ALL_GCS
  49 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
  50 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
  51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  52 #include "gc_implementation/parNew/parNewGeneration.hpp"
  53 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  54 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
  55 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
  56 #include "services/g1MemoryPool.hpp"
  57 #include "services/psMemoryPool.hpp"
  58 #include "services/shenandoahMemoryPool.hpp"
  59 #endif // INCLUDE_ALL_GCS
  60 
  61 GrowableArray<MemoryPool*>* MemoryService::_pools_list =
  62   new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_pools_list_size, true);
  63 GrowableArray<MemoryManager*>* MemoryService::_managers_list =
  64   new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryManager*>(init_managers_list_size, true);
  65 
  66 GCMemoryManager* MemoryService::_minor_gc_manager      = NULL;
  67 GCMemoryManager* MemoryService::_major_gc_manager      = NULL;
  68 MemoryPool*      MemoryService::_code_heap_pool        = NULL;
  69 MemoryPool*      MemoryService::_metaspace_pool        = NULL;
  70 MemoryPool*      MemoryService::_compressed_class_pool = NULL;
  71 
  72 class GcThreadCountClosure: public ThreadClosure {
  73  private:
  74   int _count;
  75  public:
  76   GcThreadCountClosure() : _count(0) {};
  77   void do_thread(Thread* thread);
  78   int count() { return _count; }


  81 void GcThreadCountClosure::do_thread(Thread* thread) {
  82   _count++;
  83 }
  84 
  85 void MemoryService::set_universe_heap(CollectedHeap* heap) {
  86   CollectedHeap::Name kind = heap->kind();
  87   switch (kind) {
  88     case CollectedHeap::GenCollectedHeap : {
  89       add_gen_collected_heap_info(GenCollectedHeap::heap());
  90       break;
  91     }
  92 #if INCLUDE_ALL_GCS
  93     case CollectedHeap::ParallelScavengeHeap : {
  94       add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap());
  95       break;
  96     }
  97     case CollectedHeap::G1CollectedHeap : {
  98       add_g1_heap_info(G1CollectedHeap::heap());
  99       break;
 100     }
 101   case CollectedHeap::ShenandoahHeap : {
 102     add_shenandoah_heap_info(ShenandoahHeap::heap());
 103     break;
 104   }
 105 #endif // INCLUDE_ALL_GCS
 106     default: {
 107       guarantee(false, "Unrecognized kind of heap");
 108     }
 109   }
 110 
 111   // set the GC thread count
 112   GcThreadCountClosure gctcc;
 113   heap->gc_threads_do(&gctcc);
 114   int count = gctcc.count();
 115   if (count > 0) {
 116     _minor_gc_manager->set_num_gc_threads(count);
 117     _major_gc_manager->set_num_gc_threads(count);
 118   }
 119 
 120   // All memory pools and memory managers are initialized.
 121   //
 122   _minor_gc_manager->initialize_gc_stat_info();
 123   _major_gc_manager->initialize_gc_stat_info();
 124 }


 178   _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
 179   _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
 180   _managers_list->append(_minor_gc_manager);
 181   _managers_list->append(_major_gc_manager);
 182 
 183   add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
 184   add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
 185 }
 186 
 187 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
 188   assert(UseG1GC, "sanity");
 189 
 190   _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
 191   _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
 192   _managers_list->append(_minor_gc_manager);
 193   _managers_list->append(_major_gc_manager);
 194 
 195   add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
 196   add_g1OldGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
 197 }
 198 
 199 void MemoryService::add_shenandoah_heap_info(ShenandoahHeap* heap) {
 200   assert(UseShenandoahGC, "sanity");
 201 
 202   // We reuse the "minor/major" names, even though they make little sense
 203   // in Shenandoah. JDK 10+ makes this right, but not JDK 9-.
 204   _major_gc_manager = MemoryManager::get_shenandoah_pauses_memory_manager();
 205   _minor_gc_manager = MemoryManager::get_shenandoah_cycles_memory_manager();
 206   _managers_list->append(_major_gc_manager);
 207   _managers_list->append(_minor_gc_manager);
 208 
 209   ShenandoahMemoryPool* pool = new ShenandoahMemoryPool(heap);
 210   _pools_list->append(pool);
 211 
 212   _major_gc_manager->add_pool(pool);
 213   _minor_gc_manager->add_pool(pool);
 214 }
 215 
 216 #endif // INCLUDE_ALL_GCS
 217 
 218 MemoryPool* MemoryService::add_gen(Generation* gen,
 219                                    const char* name,
 220                                    bool is_heap,
 221                                    bool support_usage_threshold) {
 222 
 223   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
 224   GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
 225   _pools_list->append(pool);
 226   return (MemoryPool*) pool;
 227 }
 228 
 229 MemoryPool* MemoryService::add_space(ContiguousSpace* space,
 230                                      const char* name,
 231                                      bool is_heap,
 232                                      size_t max_size,
 233                                      bool support_usage_threshold) {
 234   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
 235   ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold);


< prev index next >