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