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