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