1 /* 2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 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 #include "precompiled.hpp" 26 #include "classfile/systemDictionary.hpp" 27 #include "classfile/vmSymbols.hpp" 28 #include "gc/parallel/mutableSpace.hpp" 29 #include "gc/serial/defNewGeneration.hpp" 30 #include "gc/serial/tenuredGeneration.hpp" 31 #include "gc/shared/collectorPolicy.hpp" 32 #include "gc/shared/genCollectedHeap.hpp" 33 #include "gc/shared/generation.hpp" 34 #include "gc/shared/generationSpec.hpp" 35 #include "memory/heap.hpp" 36 #include "memory/memRegion.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/shenandoah/shenandoahHeap.hpp" 50 #include "gc/cms/concurrentMarkSweepGeneration.hpp" 51 #include "gc/cms/parNewGeneration.hpp" 52 #include "gc/g1/g1CollectedHeap.inline.hpp" 53 #include "gc/parallel/parallelScavengeHeap.hpp" 54 #include "gc/parallel/psOldGen.hpp" 55 #include "gc/parallel/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 MemoryManager* MemoryService::_code_cache_manager = NULL; 69 GrowableArray<MemoryPool*>* MemoryService::_code_heap_pools = 70 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_code_heap_pools_size, true); 71 MemoryPool* MemoryService::_metaspace_pool = NULL; 72 MemoryPool* MemoryService::_compressed_class_pool = NULL; 73 74 class GcThreadCountClosure: public ThreadClosure { 75 private: 76 int _count; 77 public: 78 GcThreadCountClosure() : _count(0) {}; 79 void do_thread(Thread* thread); 80 int count() { return _count; } 81 }; 82 83 void GcThreadCountClosure::do_thread(Thread* thread) { 84 _count++; 85 } 86 87 void MemoryService::set_universe_heap(CollectedHeap* heap) { 88 CollectedHeap::Name kind = heap->kind(); 89 switch (kind) { 90 case CollectedHeap::GenCollectedHeap : { 91 add_gen_collected_heap_info(GenCollectedHeap::heap()); 92 break; 93 } 94 #if INCLUDE_ALL_GCS 95 case CollectedHeap::ParallelScavengeHeap : { 96 add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap()); 97 break; 98 } 99 case CollectedHeap::G1CollectedHeap : { 100 add_g1_heap_info(G1CollectedHeap::heap()); 101 break; 102 } 103 case CollectedHeap::ShenandoahHeap : { 104 add_shenandoah_heap_info(ShenandoahHeap::heap()); 105 break; 106 } 107 #endif // INCLUDE_ALL_GCS 108 default: { 109 guarantee(false, "Unrecognized kind of heap"); 110 } 111 } 112 113 // set the GC thread count 114 GcThreadCountClosure gctcc; 115 heap->gc_threads_do(&gctcc); 116 int count = gctcc.count(); 117 if (count > 0) { 118 _minor_gc_manager->set_num_gc_threads(count); 119 _major_gc_manager->set_num_gc_threads(count); 120 } 121 122 // All memory pools and memory managers are initialized. 123 // 124 if (UseShenandoahGC) { 125 _major_gc_manager->initialize_gc_stat_info(); 126 } else { 127 _minor_gc_manager->initialize_gc_stat_info(); 128 _major_gc_manager->initialize_gc_stat_info(); 129 } 130 } 131 132 // Add memory pools for GenCollectedHeap 133 // This function currently only supports two generations collected heap. 134 // The collector for GenCollectedHeap will have two memory managers. 135 void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) { 136 CollectorPolicy* policy = heap->collector_policy(); 137 138 assert(policy->is_generation_policy(), "Only support two generations"); 139 GenCollectorPolicy* gen_policy = policy->as_generation_policy(); 140 if (gen_policy != NULL) { 141 Generation::Name kind = gen_policy->young_gen_spec()->name(); 142 switch (kind) { 143 case Generation::DefNew: 144 _minor_gc_manager = MemoryManager::get_copy_memory_manager(); 145 break; 146 #if INCLUDE_ALL_GCS 147 case Generation::ParNew: 148 _minor_gc_manager = MemoryManager::get_parnew_memory_manager(); 149 break; 150 #endif // INCLUDE_ALL_GCS 151 default: 152 guarantee(false, "Unrecognized generation spec"); 153 break; 154 } 155 if (policy->is_mark_sweep_policy()) { 156 _major_gc_manager = MemoryManager::get_msc_memory_manager(); 157 #if INCLUDE_ALL_GCS 158 } else if (policy->is_concurrent_mark_sweep_policy()) { 159 _major_gc_manager = MemoryManager::get_cms_memory_manager(); 160 #endif // INCLUDE_ALL_GCS 161 } else { 162 guarantee(false, "Unknown two-gen policy"); 163 } 164 } else { 165 guarantee(false, "Non two-gen policy"); 166 } 167 _managers_list->append(_minor_gc_manager); 168 _managers_list->append(_major_gc_manager); 169 170 add_generation_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); 171 add_generation_memory_pool(heap->old_gen(), _major_gc_manager); 172 } 173 174 #if INCLUDE_ALL_GCS 175 // Add memory pools for ParallelScavengeHeap 176 // This function currently only supports two generations collected heap. 177 // The collector for ParallelScavengeHeap will have two memory managers. 178 void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) { 179 // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC. 180 _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager(); 181 _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager(); 182 _managers_list->append(_minor_gc_manager); 183 _managers_list->append(_major_gc_manager); 184 185 add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); 186 add_psOld_memory_pool(heap->old_gen(), _major_gc_manager); 187 } 188 189 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) { 190 assert(UseG1GC, "sanity"); 191 192 _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager(); 193 _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager(); 194 _managers_list->append(_minor_gc_manager); 195 _managers_list->append(_major_gc_manager); 196 197 add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager); 198 add_g1OldGen_memory_pool(g1h, _major_gc_manager); 199 } 200 201 void MemoryService::add_shenandoah_heap_info(ShenandoahHeap* pgch) { 202 assert(UseShenandoahGC, "sanity"); 203 _major_gc_manager = MemoryManager::get_shenandoah_memory_manager(); 204 _minor_gc_manager = MemoryManager::get_shenandoah_memory_manager(); 205 _managers_list->append(_major_gc_manager); 206 add_shenandoah_memory_pool(pgch, _major_gc_manager); 207 } 208 209 #endif // INCLUDE_ALL_GCS 210 211 MemoryPool* MemoryService::add_gen(Generation* gen, 212 const char* name, 213 bool is_heap, 214 bool support_usage_threshold) { 215 216 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); 217 GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold); 218 _pools_list->append(pool); 219 return (MemoryPool*) pool; 220 } 221 222 MemoryPool* MemoryService::add_space(ContiguousSpace* space, 223 const char* name, 224 bool is_heap, 225 size_t max_size, 226 bool support_usage_threshold) { 227 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); 228 ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold); 229 230 _pools_list->append(pool); 231 return (MemoryPool*) pool; 232 } 233 234 MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* young_gen, 235 const char* name, 236 bool is_heap, 237 size_t max_size, 238 bool support_usage_threshold) { 239 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); 240 SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(young_gen, name, type, max_size, support_usage_threshold); 241 242 _pools_list->append(pool); 243 return (MemoryPool*) pool; 244 } 245 246 #if INCLUDE_ALL_GCS 247 MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space, 248 const char* name, 249 bool is_heap, 250 size_t max_size, 251 bool support_usage_threshold) { 252 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); 253 CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold); 254 _pools_list->append(pool); 255 return (MemoryPool*) pool; 256 } 257 #endif // INCLUDE_ALL_GCS 258 259 // Add memory pool(s) for one generation 260 void MemoryService::add_generation_memory_pool(Generation* gen, 261 MemoryManager* major_mgr, 262 MemoryManager* minor_mgr) { 263 guarantee(gen != NULL, "No generation for memory pool"); 264 Generation::Name kind = gen->kind(); 265 int index = _pools_list->length(); 266 267 switch (kind) { 268 case Generation::DefNew: { 269 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); 270 DefNewGeneration* young_gen = (DefNewGeneration*) gen; 271 // Add a memory pool for each space and young gen doesn't 272 // support low memory detection as it is expected to get filled up. 273 MemoryPool* eden = add_space(young_gen->eden(), 274 "Eden Space", 275 true, /* is_heap */ 276 young_gen->max_eden_size(), 277 false /* support_usage_threshold */); 278 MemoryPool* survivor = add_survivor_spaces(young_gen, 279 "Survivor Space", 280 true, /* is_heap */ 281 young_gen->max_survivor_size(), 282 false /* support_usage_threshold */); 283 break; 284 } 285 286 #if INCLUDE_ALL_GCS 287 case Generation::ParNew: 288 { 289 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); 290 // Add a memory pool for each space and young gen doesn't 291 // support low memory detection as it is expected to get filled up. 292 ParNewGeneration* parnew_gen = (ParNewGeneration*) gen; 293 MemoryPool* eden = add_space(parnew_gen->eden(), 294 "Par Eden Space", 295 true /* is_heap */, 296 parnew_gen->max_eden_size(), 297 false /* support_usage_threshold */); 298 MemoryPool* survivor = add_survivor_spaces(parnew_gen, 299 "Par Survivor Space", 300 true, /* is_heap */ 301 parnew_gen->max_survivor_size(), 302 false /* support_usage_threshold */); 303 304 break; 305 } 306 #endif // INCLUDE_ALL_GCS 307 308 case Generation::MarkSweepCompact: { 309 assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); 310 add_gen(gen, 311 "Tenured Gen", 312 true, /* is_heap */ 313 true /* support_usage_threshold */); 314 break; 315 } 316 317 #if INCLUDE_ALL_GCS 318 case Generation::ConcurrentMarkSweep: 319 { 320 assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); 321 ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen; 322 MemoryPool* pool = add_cms_space(cms->cmsSpace(), 323 "CMS Old Gen", 324 true, /* is_heap */ 325 cms->reserved().byte_size(), 326 true /* support_usage_threshold */); 327 break; 328 } 329 #endif // INCLUDE_ALL_GCS 330 331 default: 332 assert(false, "should not reach here"); 333 // no memory pool added for others 334 break; 335 } 336 337 assert(major_mgr != NULL, "Should have at least one manager"); 338 // Link managers and the memory pools together 339 for (int i = index; i < _pools_list->length(); i++) { 340 MemoryPool* pool = _pools_list->at(i); 341 major_mgr->add_pool(pool); 342 if (minor_mgr != NULL) { 343 minor_mgr->add_pool(pool); 344 } 345 } 346 } 347 348 349 #if INCLUDE_ALL_GCS 350 void MemoryService::add_psYoung_memory_pool(PSYoungGen* young_gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) { 351 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); 352 353 // Add a memory pool for each space and young gen doesn't 354 // support low memory detection as it is expected to get filled up. 355 EdenMutableSpacePool* eden = new EdenMutableSpacePool(young_gen, 356 young_gen->eden_space(), 357 "PS Eden Space", 358 MemoryPool::Heap, 359 false /* support_usage_threshold */); 360 361 SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young_gen, 362 "PS Survivor Space", 363 MemoryPool::Heap, 364 false /* support_usage_threshold */); 365 366 major_mgr->add_pool(eden); 367 major_mgr->add_pool(survivor); 368 minor_mgr->add_pool(eden); 369 minor_mgr->add_pool(survivor); 370 _pools_list->append(eden); 371 _pools_list->append(survivor); 372 } 373 374 void MemoryService::add_psOld_memory_pool(PSOldGen* old_gen, MemoryManager* mgr) { 375 PSGenerationPool* old_gen_pool = new PSGenerationPool(old_gen, 376 "PS Old Gen", 377 MemoryPool::Heap, 378 true /* support_usage_threshold */); 379 mgr->add_pool(old_gen_pool); 380 _pools_list->append(old_gen_pool); 381 } 382 383 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, 384 MemoryManager* major_mgr, 385 MemoryManager* minor_mgr) { 386 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers"); 387 388 G1EdenPool* eden = new G1EdenPool(g1h); 389 G1SurvivorPool* survivor = new G1SurvivorPool(g1h); 390 391 major_mgr->add_pool(eden); 392 major_mgr->add_pool(survivor); 393 minor_mgr->add_pool(eden); 394 minor_mgr->add_pool(survivor); 395 _pools_list->append(eden); 396 _pools_list->append(survivor); 397 } 398 399 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h, 400 MemoryManager* mgr) { 401 assert(mgr != NULL, "should have one manager"); 402 403 G1OldGenPool* old_gen = new G1OldGenPool(g1h); 404 mgr->add_pool(old_gen); 405 _pools_list->append(old_gen); 406 } 407 408 void MemoryService::add_shenandoah_memory_pool(ShenandoahHeap* pgc, 409 MemoryManager* mgr) { 410 ShenandoahMemoryPool* pool = new ShenandoahMemoryPool(pgc, 411 "Shenandoah", 412 MemoryPool::Heap, 413 false /* support_usage_threshold */); 414 415 mgr->add_pool(pool); 416 _pools_list->append(pool); 417 } 418 419 420 #endif // INCLUDE_ALL_GCS 421 422 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap, const char* name) { 423 // Create new memory pool for this heap 424 MemoryPool* code_heap_pool = new CodeHeapPool(heap, name, true /* support_usage_threshold */); 425 426 // Append to lists 427 _code_heap_pools->append(code_heap_pool); 428 _pools_list->append(code_heap_pool); 429 430 if (_code_cache_manager == NULL) { 431 // Create CodeCache memory manager 432 _code_cache_manager = MemoryManager::get_code_cache_memory_manager(); 433 _managers_list->append(_code_cache_manager); 434 } 435 436 _code_cache_manager->add_pool(code_heap_pool); 437 } 438 439 void MemoryService::add_metaspace_memory_pools() { 440 MemoryManager* mgr = MemoryManager::get_metaspace_memory_manager(); 441 442 _metaspace_pool = new MetaspacePool(); 443 mgr->add_pool(_metaspace_pool); 444 _pools_list->append(_metaspace_pool); 445 446 if (UseCompressedClassPointers) { 447 _compressed_class_pool = new CompressedKlassSpacePool(); 448 mgr->add_pool(_compressed_class_pool); 449 _pools_list->append(_compressed_class_pool); 450 } 451 452 _managers_list->append(mgr); 453 } 454 455 MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) { 456 for (int i = 0; i < _managers_list->length(); i++) { 457 MemoryManager* mgr = _managers_list->at(i); 458 if (mgr->is_manager(mh)) { 459 return mgr; 460 } 461 } 462 return NULL; 463 } 464 465 MemoryPool* MemoryService::get_memory_pool(instanceHandle ph) { 466 for (int i = 0; i < _pools_list->length(); i++) { 467 MemoryPool* pool = _pools_list->at(i); 468 if (pool->is_pool(ph)) { 469 return pool; 470 } 471 } 472 return NULL; 473 } 474 475 void MemoryService::track_memory_usage() { 476 // Track the peak memory usage 477 for (int i = 0; i < _pools_list->length(); i++) { 478 MemoryPool* pool = _pools_list->at(i); 479 pool->record_peak_memory_usage(); 480 } 481 482 // Detect low memory 483 LowMemoryDetector::detect_low_memory(); 484 } 485 486 void MemoryService::track_memory_pool_usage(MemoryPool* pool) { 487 // Track the peak memory usage 488 pool->record_peak_memory_usage(); 489 490 // Detect low memory 491 if (LowMemoryDetector::is_enabled(pool)) { 492 LowMemoryDetector::detect_low_memory(pool); 493 } 494 } 495 496 void MemoryService::gc_begin(bool fullGC, bool recordGCBeginTime, 497 bool recordAccumulatedGCTime, 498 bool recordPreGCUsage, bool recordPeakUsage) { 499 500 GCMemoryManager* mgr; 501 if (fullGC) { 502 mgr = _major_gc_manager; 503 } else { 504 mgr = _minor_gc_manager; 505 } 506 assert(mgr->is_gc_memory_manager(), "Sanity check"); 507 mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime); 508 509 // Track the peak memory usage when GC begins 510 if (recordPeakUsage) { 511 for (int i = 0; i < _pools_list->length(); i++) { 512 MemoryPool* pool = _pools_list->at(i); 513 pool->record_peak_memory_usage(); 514 } 515 } 516 } 517 518 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage, 519 bool recordAccumulatedGCTime, 520 bool recordGCEndTime, bool countCollection, 521 GCCause::Cause cause) { 522 523 GCMemoryManager* mgr; 524 if (fullGC) { 525 mgr = (GCMemoryManager*) _major_gc_manager; 526 } else { 527 mgr = (GCMemoryManager*) _minor_gc_manager; 528 } 529 assert(mgr->is_gc_memory_manager(), "Sanity check"); 530 531 // register the GC end statistics and memory usage 532 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, 533 countCollection, cause); 534 } 535 536 void MemoryService::oops_do(OopClosure* f) { 537 int i; 538 539 for (i = 0; i < _pools_list->length(); i++) { 540 MemoryPool* pool = _pools_list->at(i); 541 pool->oops_do(f); 542 } 543 for (i = 0; i < _managers_list->length(); i++) { 544 MemoryManager* mgr = _managers_list->at(i); 545 mgr->oops_do(f); 546 } 547 } 548 549 bool MemoryService::set_verbose(bool verbose) { 550 MutexLocker m(Management_lock); 551 // verbose will be set to the previous value 552 Flag::Error error = CommandLineFlags::boolAtPut("PrintGC", &verbose, Flag::MANAGEMENT); 553 assert(error==Flag::SUCCESS, err_msg("Setting PrintGC flag failed with error %s", Flag::flag_error_str(error))); 554 ClassLoadingService::reset_trace_class_unloading(); 555 556 return verbose; 557 } 558 559 Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) { 560 Klass* k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH); 561 instanceKlassHandle ik(THREAD, k); 562 563 instanceHandle obj = ik->allocate_instance_handle(CHECK_NH); 564 565 JavaValue result(T_VOID); 566 JavaCallArguments args(10); 567 args.push_oop(obj); // receiver 568 args.push_long(usage.init_size_as_jlong()); // Argument 1 569 args.push_long(usage.used_as_jlong()); // Argument 2 570 args.push_long(usage.committed_as_jlong()); // Argument 3 571 args.push_long(usage.max_size_as_jlong()); // Argument 4 572 573 JavaCalls::call_special(&result, 574 ik, 575 vmSymbols::object_initializer_name(), 576 vmSymbols::long_long_long_long_void_signature(), 577 &args, 578 CHECK_NH); 579 return obj; 580 } 581 // 582 // GC manager type depends on the type of Generation. Depending on the space 583 // availability and vm options the gc uses major gc manager or minor gc 584 // manager or both. The type of gc manager depends on the generation kind. 585 // For DefNew and ParNew generation doing scavenge gc uses minor gc manager (so 586 // _fullGC is set to false ) and for other generation kinds doing 587 // mark-sweep-compact uses major gc manager (so _fullGC is set to true). 588 TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) { 589 switch (kind) { 590 case Generation::DefNew: 591 #if INCLUDE_ALL_GCS 592 case Generation::ParNew: 593 #endif // INCLUDE_ALL_GCS 594 _fullGC=false; 595 break; 596 case Generation::MarkSweepCompact: 597 #if INCLUDE_ALL_GCS 598 case Generation::ConcurrentMarkSweep: 599 #endif // INCLUDE_ALL_GCS 600 _fullGC=true; 601 break; 602 default: 603 assert(false, "Unrecognized gc generation kind."); 604 } 605 // this has to be called in a stop the world pause and represent 606 // an entire gc pause, start to finish: 607 initialize(_fullGC, cause,true, true, true, true, true, true, true); 608 } 609 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC, 610 GCCause::Cause cause, 611 bool recordGCBeginTime, 612 bool recordPreGCUsage, 613 bool recordPeakUsage, 614 bool recordPostGCUsage, 615 bool recordAccumulatedGCTime, 616 bool recordGCEndTime, 617 bool countCollection) { 618 initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, 619 recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, 620 countCollection); 621 } 622 623 // for a subclass to create then initialize an instance before invoking 624 // the MemoryService 625 void TraceMemoryManagerStats::initialize(bool fullGC, 626 GCCause::Cause cause, 627 bool recordGCBeginTime, 628 bool recordPreGCUsage, 629 bool recordPeakUsage, 630 bool recordPostGCUsage, 631 bool recordAccumulatedGCTime, 632 bool recordGCEndTime, 633 bool countCollection) { 634 _fullGC = fullGC; 635 _recordGCBeginTime = recordGCBeginTime; 636 _recordPreGCUsage = recordPreGCUsage; 637 _recordPeakUsage = recordPeakUsage; 638 _recordPostGCUsage = recordPostGCUsage; 639 _recordAccumulatedGCTime = recordAccumulatedGCTime; 640 _recordGCEndTime = recordGCEndTime; 641 _countCollection = countCollection; 642 _cause = cause; 643 644 MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime, 645 _recordPreGCUsage, _recordPeakUsage); 646 } 647 648 TraceMemoryManagerStats::~TraceMemoryManagerStats() { 649 MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime, 650 _recordGCEndTime, _countCollection, _cause); 651 }