< prev index next >

src/hotspot/share/services/memoryManager.cpp

Print this page




 193 
 194 void GCMemoryManager::add_pool(MemoryPool* pool) {
 195   add_pool(pool, true);
 196 }
 197 
 198 void GCMemoryManager::add_pool(MemoryPool* pool, bool always_affected_by_gc) {
 199   int index = MemoryManager::add_pool(pool);
 200   _pool_always_affected_by_gc[index] = always_affected_by_gc;
 201 }
 202 
 203 void GCMemoryManager::initialize_gc_stat_info() {
 204   assert(MemoryService::num_memory_pools() > 0, "should have one or more memory pools");
 205   _last_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
 206   _current_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
 207   // tracking concurrent collections we need two objects: one to update, and one to
 208   // hold the publicly available "last (completed) gc" information.
 209 }
 210 
 211 void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
 212                                bool recordAccumulatedGCTime) {
 213   assert(_last_gc_stat != NULL && _current_gc_stat != NULL, "Just checking");


 214   if (recordAccumulatedGCTime) {
 215     _accumulated_timer.start();
 216   }
 217   // _num_collections now increases in gc_end, to count completed collections
 218   if (recordGCBeginTime) {
 219     _current_gc_stat->set_index(_num_collections+1);
 220     _current_gc_stat->set_start_time(Management::timestamp());
 221   }
 222 
 223   if (recordPreGCUsage) {
 224     // Keep memory usage of all memory pools
 225     for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
 226       MemoryPool* pool = MemoryService::get_memory_pool(i);
 227       MemoryUsage usage = pool->get_memory_usage();
 228       _current_gc_stat->set_before_gc_usage(i, usage);
 229       HOTSPOT_MEM_POOL_GC_BEGIN(
 230         (char *) name(), strlen(name()),
 231         (char *) pool->name(), strlen(pool->name()),
 232         usage.init_size(), usage.used(),
 233         usage.committed(), usage.max_size());
 234     }
 235   }
 236 }
 237 
 238 // A collector MUST, even if it does not complete for some reason,
 239 // make a TraceMemoryManagerStats object where countCollection is true,
 240 // to ensure the current gc stat is placed in _last_gc_stat.
 241 void GCMemoryManager::gc_end(bool recordPostGCUsage,
 242                              bool recordAccumulatedGCTime,
 243                              bool recordGCEndTime, bool countCollection,
 244                              GCCause::Cause cause,
 245                              bool allMemoryPoolsAffected) {


 246   if (recordAccumulatedGCTime) {
 247     _accumulated_timer.stop();
 248   }
 249   if (recordGCEndTime) {
 250     _current_gc_stat->set_end_time(Management::timestamp());
 251   }
 252 
 253   if (recordPostGCUsage) {
 254     int i;
 255     // keep the last gc statistics for all memory pools
 256     for (i = 0; i < MemoryService::num_memory_pools(); i++) {
 257       MemoryPool* pool = MemoryService::get_memory_pool(i);
 258       MemoryUsage usage = pool->get_memory_usage();
 259 
 260       HOTSPOT_MEM_POOL_GC_END(
 261         (char *) name(), strlen(name()),
 262         (char *) pool->name(), strlen(pool->name()),
 263         usage.init_size(), usage.used(),
 264         usage.committed(), usage.max_size());
 265 




 193 
 194 void GCMemoryManager::add_pool(MemoryPool* pool) {
 195   add_pool(pool, true);
 196 }
 197 
 198 void GCMemoryManager::add_pool(MemoryPool* pool, bool always_affected_by_gc) {
 199   int index = MemoryManager::add_pool(pool);
 200   _pool_always_affected_by_gc[index] = always_affected_by_gc;
 201 }
 202 
 203 void GCMemoryManager::initialize_gc_stat_info() {
 204   assert(MemoryService::num_memory_pools() > 0, "should have one or more memory pools");
 205   _last_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
 206   _current_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
 207   // tracking concurrent collections we need two objects: one to update, and one to
 208   // hold the publicly available "last (completed) gc" information.
 209 }
 210 
 211 void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
 212                                bool recordAccumulatedGCTime) {
 213   // Inactive memory managers (concurrent in G1 legacy mode) will not be initialized.
 214   if (_last_gc_stat == NULL && _current_gc_stat == NULL) return;
 215 
 216   if (recordAccumulatedGCTime) {
 217     _accumulated_timer.start();
 218   }
 219   // _num_collections now increases in gc_end, to count completed collections
 220   if (recordGCBeginTime) {
 221     _current_gc_stat->set_index(_num_collections+1);
 222     _current_gc_stat->set_start_time(Management::timestamp());
 223   }
 224 
 225   if (recordPreGCUsage) {
 226     // Keep memory usage of all memory pools
 227     for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
 228       MemoryPool* pool = MemoryService::get_memory_pool(i);
 229       MemoryUsage usage = pool->get_memory_usage();
 230       _current_gc_stat->set_before_gc_usage(i, usage);
 231       HOTSPOT_MEM_POOL_GC_BEGIN(
 232         (char *) name(), strlen(name()),
 233         (char *) pool->name(), strlen(pool->name()),
 234         usage.init_size(), usage.used(),
 235         usage.committed(), usage.max_size());
 236     }
 237   }
 238 }
 239 
 240 // A collector MUST, even if it does not complete for some reason,
 241 // make a TraceMemoryManagerStats object where countCollection is true,
 242 // to ensure the current gc stat is placed in _last_gc_stat.
 243 void GCMemoryManager::gc_end(bool recordPostGCUsage,
 244                              bool recordAccumulatedGCTime,
 245                              bool recordGCEndTime, bool countCollection,
 246                              GCCause::Cause cause,
 247                              bool allMemoryPoolsAffected) {
 248   if (_last_gc_stat == NULL && _current_gc_stat == NULL) return;
 249 
 250   if (recordAccumulatedGCTime) {
 251     _accumulated_timer.stop();
 252   }
 253   if (recordGCEndTime) {
 254     _current_gc_stat->set_end_time(Management::timestamp());
 255   }
 256 
 257   if (recordPostGCUsage) {
 258     int i;
 259     // keep the last gc statistics for all memory pools
 260     for (i = 0; i < MemoryService::num_memory_pools(); i++) {
 261       MemoryPool* pool = MemoryService::get_memory_pool(i);
 262       MemoryUsage usage = pool->get_memory_usage();
 263 
 264       HOTSPOT_MEM_POOL_GC_END(
 265         (char *) name(), strlen(name()),
 266         (char *) pool->name(), strlen(pool->name()),
 267         usage.init_size(), usage.used(),
 268         usage.committed(), usage.max_size());
 269 


< prev index next >