1 /* 2 * Copyright (c) 2001, 2024, 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 "cds/cdsConfig.hpp" 27 #include "classfile/classLoaderData.hpp" 28 #include "classfile/vmClasses.hpp" 29 #include "gc/shared/allocTracer.hpp" 30 #include "gc/shared/barrierSet.hpp" 31 #include "gc/shared/collectedHeap.hpp" 32 #include "gc/shared/collectedHeap.inline.hpp" 33 #include "gc/shared/gcLocker.inline.hpp" 34 #include "gc/shared/gcHeapSummary.hpp" 35 #include "gc/shared/stringdedup/stringDedup.hpp" 36 #include "gc/shared/gcTrace.hpp" 37 #include "gc/shared/gcTraceTime.inline.hpp" 38 #include "gc/shared/gcVMOperations.hpp" 39 #include "gc/shared/gcWhen.hpp" 40 #include "gc/shared/gc_globals.hpp" 41 #include "gc/shared/memAllocator.hpp" 42 #include "gc/shared/tlab_globals.hpp" 43 #include "logging/log.hpp" 44 #include "logging/logStream.hpp" 45 #include "memory/classLoaderMetaspace.hpp" 46 #include "memory/metaspace.hpp" 47 #include "memory/metaspaceUtils.hpp" 48 #include "memory/resourceArea.hpp" 49 #include "memory/universe.hpp" 50 #include "oops/instanceMirrorKlass.hpp" 51 #include "oops/oop.inline.hpp" 52 #include "runtime/handles.inline.hpp" 53 #include "runtime/init.hpp" 54 #include "runtime/javaThread.hpp" 55 #include "runtime/perfData.hpp" 56 #include "runtime/threadSMR.hpp" 57 #include "runtime/vmThread.hpp" 58 #include "services/heapDumper.hpp" 59 #include "utilities/align.hpp" 60 #include "utilities/copy.hpp" 61 #include "utilities/events.hpp" 62 63 class ClassLoaderData; 64 65 size_t CollectedHeap::_lab_alignment_reserve = SIZE_MAX; 66 Klass* CollectedHeap::_filler_object_klass = nullptr; 67 size_t CollectedHeap::_filler_array_max_size = 0; 68 size_t CollectedHeap::_stack_chunk_max_size = 0; 69 70 class GCMessage : public FormatBuffer<1024> { 71 public: 72 bool is_before; 73 }; 74 75 template <> 76 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) { 77 st->print_cr("GC heap %s", m.is_before ? "before" : "after"); 78 st->print_raw(m); 79 } 80 81 class GCHeapLog : public EventLogBase<GCMessage> { 82 private: 83 void log_heap(CollectedHeap* heap, bool before); 84 85 public: 86 GCHeapLog() : EventLogBase<GCMessage>("GC Heap History", "gc") {} 87 88 void log_heap_before(CollectedHeap* heap) { 89 log_heap(heap, true); 90 } 91 void log_heap_after(CollectedHeap* heap) { 92 log_heap(heap, false); 93 } 94 }; 95 96 void GCHeapLog::log_heap(CollectedHeap* heap, bool before) { 97 if (!should_log()) { 98 return; 99 } 100 101 double timestamp = fetch_timestamp(); 102 MutexLocker ml(&_mutex, Mutex::_no_safepoint_check_flag); 103 int index = compute_log_index(); 104 _records[index].thread = nullptr; // Its the GC thread so it's not that interesting. 105 _records[index].timestamp = timestamp; 106 _records[index].data.is_before = before; 107 stringStream st(_records[index].data.buffer(), _records[index].data.size()); 108 109 st.print_cr("{Heap %s GC invocations=%u (full %u):", 110 before ? "before" : "after", 111 heap->total_collections(), 112 heap->total_full_collections()); 113 114 heap->print_on(&st); 115 st.print_cr("}"); 116 } 117 118 ParallelObjectIterator::ParallelObjectIterator(uint thread_num) : 119 _impl(Universe::heap()->parallel_object_iterator(thread_num)) 120 {} 121 122 ParallelObjectIterator::~ParallelObjectIterator() { 123 delete _impl; 124 } 125 126 void ParallelObjectIterator::object_iterate(ObjectClosure* cl, uint worker_id) { 127 _impl->object_iterate(cl, worker_id); 128 } 129 130 size_t CollectedHeap::unused() const { 131 MutexLocker ml(Heap_lock); 132 return capacity() - used(); 133 } 134 135 VirtualSpaceSummary CollectedHeap::create_heap_space_summary() { 136 size_t capacity_in_words = capacity() / HeapWordSize; 137 138 return VirtualSpaceSummary( 139 _reserved.start(), _reserved.start() + capacity_in_words, _reserved.end()); 140 } 141 142 GCHeapSummary CollectedHeap::create_heap_summary() { 143 VirtualSpaceSummary heap_space = create_heap_space_summary(); 144 return GCHeapSummary(heap_space, used()); 145 } 146 147 MetaspaceSummary CollectedHeap::create_metaspace_summary() { 148 const MetaspaceChunkFreeListSummary& ms_chunk_free_list_summary = 149 MetaspaceUtils::chunk_free_list_summary(Metaspace::NonClassType); 150 const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary = 151 MetaspaceUtils::chunk_free_list_summary(Metaspace::ClassType); 152 return MetaspaceSummary(MetaspaceGC::capacity_until_GC(), 153 MetaspaceUtils::get_combined_statistics(), 154 ms_chunk_free_list_summary, class_chunk_free_list_summary); 155 } 156 157 bool CollectedHeap::contains_null(const oop* p) const { 158 return *p == nullptr; 159 } 160 161 void CollectedHeap::print_heap_before_gc() { 162 LogTarget(Debug, gc, heap) lt; 163 if (lt.is_enabled()) { 164 LogStream ls(lt); 165 ls.print_cr("Heap before GC invocations=%u (full %u):", total_collections(), total_full_collections()); 166 ResourceMark rm; 167 print_on(&ls); 168 } 169 170 if (_gc_heap_log != nullptr) { 171 _gc_heap_log->log_heap_before(this); 172 } 173 } 174 175 void CollectedHeap::print_heap_after_gc() { 176 LogTarget(Debug, gc, heap) lt; 177 if (lt.is_enabled()) { 178 LogStream ls(lt); 179 ls.print_cr("Heap after GC invocations=%u (full %u):", total_collections(), total_full_collections()); 180 ResourceMark rm; 181 print_on(&ls); 182 } 183 184 if (_gc_heap_log != nullptr) { 185 _gc_heap_log->log_heap_after(this); 186 } 187 } 188 189 void CollectedHeap::print() const { print_on(tty); } 190 191 void CollectedHeap::print_on_error(outputStream* st) const { 192 st->print_cr("Heap:"); 193 print_extended_on(st); 194 st->cr(); 195 196 BarrierSet* bs = BarrierSet::barrier_set(); 197 if (bs != nullptr) { 198 bs->print_on(st); 199 } 200 } 201 202 void CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) { 203 const GCHeapSummary& heap_summary = create_heap_summary(); 204 gc_tracer->report_gc_heap_summary(when, heap_summary); 205 206 const MetaspaceSummary& metaspace_summary = create_metaspace_summary(); 207 gc_tracer->report_metaspace_summary(when, metaspace_summary); 208 } 209 210 void CollectedHeap::trace_heap_before_gc(const GCTracer* gc_tracer) { 211 trace_heap(GCWhen::BeforeGC, gc_tracer); 212 } 213 214 void CollectedHeap::trace_heap_after_gc(const GCTracer* gc_tracer) { 215 trace_heap(GCWhen::AfterGC, gc_tracer); 216 } 217 218 // Default implementation, for collectors that don't support the feature. 219 bool CollectedHeap::supports_concurrent_gc_breakpoints() const { 220 return false; 221 } 222 223 bool CollectedHeap::is_oop(oop object) const { 224 if (!is_object_aligned(object)) { 225 return false; 226 } 227 228 if (!is_in(object)) { 229 return false; 230 } 231 232 // With compact headers, we can't safely access the class, due 233 // to possibly forwarded objects. 234 if (!UseCompactObjectHeaders && !Metaspace::contains(object->klass_without_asserts())) { 235 return false; 236 } 237 238 return true; 239 } 240 241 // Memory state functions. 242 243 244 CollectedHeap::CollectedHeap() : 245 _capacity_at_last_gc(0), 246 _used_at_last_gc(0), 247 _soft_ref_policy(), 248 _is_stw_gc_active(false), 249 _last_whole_heap_examined_time_ns(os::javaTimeNanos()), 250 _total_collections(0), 251 _total_full_collections(0), 252 _gc_cause(GCCause::_no_gc), 253 _gc_lastcause(GCCause::_no_gc) 254 { 255 // If the minimum object size is greater than MinObjAlignment, we can 256 // end up with a shard at the end of the buffer that's smaller than 257 // the smallest object. We can't allow that because the buffer must 258 // look like it's full of objects when we retire it, so we make 259 // sure we have enough space for a filler int array object. 260 size_t min_size = min_dummy_object_size(); 261 _lab_alignment_reserve = min_size > (size_t)MinObjAlignment ? align_object_size(min_size) : 0; 262 263 const size_t max_len = size_t(arrayOopDesc::max_array_length(T_INT)); 264 const size_t elements_per_word = HeapWordSize / sizeof(jint); 265 _filler_array_max_size = align_object_size(filler_array_hdr_size() + 266 max_len / elements_per_word); 267 268 NOT_PRODUCT(_promotion_failure_alot_count = 0;) 269 NOT_PRODUCT(_promotion_failure_alot_gc_number = 0;) 270 271 if (UsePerfData) { 272 EXCEPTION_MARK; 273 274 // create the gc cause jvmstat counters 275 _perf_gc_cause = PerfDataManager::create_string_variable(SUN_GC, "cause", 276 80, GCCause::to_string(_gc_cause), CHECK); 277 278 _perf_gc_lastcause = 279 PerfDataManager::create_string_variable(SUN_GC, "lastCause", 280 80, GCCause::to_string(_gc_lastcause), CHECK); 281 } 282 283 // Create the ring log 284 if (LogEvents) { 285 _gc_heap_log = new GCHeapLog(); 286 } else { 287 _gc_heap_log = nullptr; 288 } 289 } 290 291 // This interface assumes that it's being called by the 292 // vm thread. It collects the heap assuming that the 293 // heap lock is already held and that we are executing in 294 // the context of the vm thread. 295 void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) { 296 Thread* thread = Thread::current(); 297 assert(thread->is_VM_thread(), "Precondition#1"); 298 assert(Heap_lock->is_locked(), "Precondition#2"); 299 GCCauseSetter gcs(this, cause); 300 switch (cause) { 301 case GCCause::_codecache_GC_threshold: 302 case GCCause::_codecache_GC_aggressive: 303 case GCCause::_heap_inspection: 304 case GCCause::_heap_dump: 305 case GCCause::_metadata_GC_threshold: { 306 HandleMark hm(thread); 307 do_full_collection(false); // don't clear all soft refs 308 break; 309 } 310 case GCCause::_metadata_GC_clear_soft_refs: { 311 HandleMark hm(thread); 312 do_full_collection(true); // do clear all soft refs 313 break; 314 } 315 default: 316 ShouldNotReachHere(); // Unexpected use of this function 317 } 318 } 319 320 MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, 321 size_t word_size, 322 Metaspace::MetadataType mdtype) { 323 uint loop_count = 0; 324 uint gc_count = 0; 325 uint full_gc_count = 0; 326 327 assert(!Heap_lock->owned_by_self(), "Should not be holding the Heap_lock"); 328 329 do { 330 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); 331 if (result != nullptr) { 332 return result; 333 } 334 335 if (GCLocker::is_active_and_needs_gc()) { 336 // If the GCLocker is active, just expand and allocate. 337 // If that does not succeed, wait if this thread is not 338 // in a critical section itself. 339 result = loader_data->metaspace_non_null()->expand_and_allocate(word_size, mdtype); 340 if (result != nullptr) { 341 return result; 342 } 343 JavaThread* jthr = JavaThread::current(); 344 if (!jthr->in_critical()) { 345 // Wait for JNI critical section to be exited 346 GCLocker::stall_until_clear(); 347 // The GC invoked by the last thread leaving the critical 348 // section will be a young collection and a full collection 349 // is (currently) needed for unloading classes so continue 350 // to the next iteration to get a full GC. 351 continue; 352 } else { 353 if (CheckJNICalls) { 354 fatal("Possible deadlock due to allocating while" 355 " in jni critical section"); 356 } 357 return nullptr; 358 } 359 } 360 361 { // Need lock to get self consistent gc_count's 362 MutexLocker ml(Heap_lock); 363 gc_count = Universe::heap()->total_collections(); 364 full_gc_count = Universe::heap()->total_full_collections(); 365 } 366 367 // Generate a VM operation 368 VM_CollectForMetadataAllocation op(loader_data, 369 word_size, 370 mdtype, 371 gc_count, 372 full_gc_count, 373 GCCause::_metadata_GC_threshold); 374 VMThread::execute(&op); 375 376 // If GC was locked out, try again. Check before checking success because the 377 // prologue could have succeeded and the GC still have been locked out. 378 if (op.gc_locked()) { 379 continue; 380 } 381 382 if (op.prologue_succeeded()) { 383 return op.result(); 384 } 385 loop_count++; 386 if ((QueuedAllocationWarningCount > 0) && 387 (loop_count % QueuedAllocationWarningCount == 0)) { 388 log_warning(gc, ergo)("satisfy_failed_metadata_allocation() retries %d times," 389 " size=" SIZE_FORMAT, loop_count, word_size); 390 } 391 } while (true); // Until a GC is done 392 } 393 394 MemoryUsage CollectedHeap::memory_usage() { 395 return MemoryUsage(InitialHeapSize, used(), capacity(), max_capacity()); 396 } 397 398 void CollectedHeap::set_gc_cause(GCCause::Cause v) { 399 if (UsePerfData) { 400 _gc_lastcause = _gc_cause; 401 _perf_gc_lastcause->set_value(GCCause::to_string(_gc_lastcause)); 402 _perf_gc_cause->set_value(GCCause::to_string(v)); 403 } 404 _gc_cause = v; 405 } 406 407 // Returns the header size in words aligned to the requirements of the 408 // array object type. 409 static int int_array_header_size() { 410 size_t typesize_in_bytes = arrayOopDesc::header_size_in_bytes(); 411 return (int)align_up(typesize_in_bytes, HeapWordSize)/HeapWordSize; 412 } 413 414 size_t CollectedHeap::max_tlab_size() const { 415 // TLABs can't be bigger than we can fill with a int[Integer.MAX_VALUE]. 416 // This restriction could be removed by enabling filling with multiple arrays. 417 // If we compute that the reasonable way as 418 // header_size + ((sizeof(jint) * max_jint) / HeapWordSize) 419 // we'll overflow on the multiply, so we do the divide first. 420 // We actually lose a little by dividing first, 421 // but that just makes the TLAB somewhat smaller than the biggest array, 422 // which is fine, since we'll be able to fill that. 423 size_t max_int_size = int_array_header_size() + 424 sizeof(jint) * 425 ((juint) max_jint / (size_t) HeapWordSize); 426 return align_down(max_int_size, MinObjAlignment); 427 } 428 429 size_t CollectedHeap::filler_array_hdr_size() { 430 return align_object_offset(int_array_header_size()); // align to Long 431 } 432 433 size_t CollectedHeap::filler_array_min_size() { 434 return align_object_size(filler_array_hdr_size()); // align to MinObjAlignment 435 } 436 437 void CollectedHeap::zap_filler_array_with(HeapWord* start, size_t words, juint value) { 438 Copy::fill_to_words(start + filler_array_hdr_size(), 439 words - filler_array_hdr_size(), value); 440 } 441 442 #ifdef ASSERT 443 void CollectedHeap::fill_args_check(HeapWord* start, size_t words) 444 { 445 assert(words >= min_fill_size(), "too small to fill"); 446 assert(is_object_aligned(words), "unaligned size"); 447 } 448 449 void CollectedHeap::zap_filler_array(HeapWord* start, size_t words, bool zap) 450 { 451 if (ZapFillerObjects && zap) { 452 zap_filler_array_with(start, words, 0XDEAFBABE); 453 } 454 } 455 #endif // ASSERT 456 457 void 458 CollectedHeap::fill_with_array(HeapWord* start, size_t words, bool zap) 459 { 460 assert(words >= filler_array_min_size(), "too small for an array"); 461 assert(words <= filler_array_max_size(), "too big for a single object"); 462 463 const size_t payload_size = words - filler_array_hdr_size(); 464 const size_t len = payload_size * HeapWordSize / sizeof(jint); 465 assert((int)len >= 0, "size too large " SIZE_FORMAT " becomes %d", words, (int)len); 466 467 ObjArrayAllocator allocator(Universe::fillerArrayKlass(), words, (int)len, /* do_zero */ false); 468 allocator.initialize(start); 469 if (CDSConfig::is_dumping_heap()) { 470 // This array is written into the CDS archive. Make sure it 471 // has deterministic contents. 472 zap_filler_array_with(start, words, 0); 473 } else { 474 DEBUG_ONLY(zap_filler_array(start, words, zap);) 475 } 476 } 477 478 void 479 CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap) 480 { 481 assert(words <= filler_array_max_size(), "too big for a single object"); 482 483 if (words >= filler_array_min_size()) { 484 fill_with_array(start, words, zap); 485 } else if (words > 0) { 486 assert(words == min_fill_size(), "unaligned size"); 487 ObjAllocator allocator(CollectedHeap::filler_object_klass(), words); 488 allocator.initialize(start); 489 } 490 } 491 492 void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap) 493 { 494 DEBUG_ONLY(fill_args_check(start, words);) 495 HandleMark hm(Thread::current()); // Free handles before leaving. 496 fill_with_object_impl(start, words, zap); 497 } 498 499 void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap) 500 { 501 DEBUG_ONLY(fill_args_check(start, words);) 502 HandleMark hm(Thread::current()); // Free handles before leaving. 503 504 // Multiple objects may be required depending on the filler array maximum size. Fill 505 // the range up to that with objects that are filler_array_max_size sized. The 506 // remainder is filled with a single object. 507 const size_t min = min_fill_size(); 508 const size_t max = filler_array_max_size(); 509 while (words > max) { 510 const size_t cur = (words - max) >= min ? max : max - min; 511 fill_with_array(start, cur, zap); 512 start += cur; 513 words -= cur; 514 } 515 516 fill_with_object_impl(start, words, zap); 517 } 518 519 void CollectedHeap::fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap) { 520 CollectedHeap::fill_with_object(start, end, zap); 521 } 522 523 void CollectedHeap::ensure_parsability(bool retire_tlabs) { 524 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), 525 "Should only be called at a safepoint or at start-up"); 526 527 ThreadLocalAllocStats stats; 528 529 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next();) { 530 BarrierSet::barrier_set()->make_parsable(thread); 531 if (UseTLAB) { 532 if (retire_tlabs) { 533 thread->tlab().retire(&stats); 534 } else { 535 thread->tlab().make_parsable(); 536 } 537 } 538 } 539 540 stats.publish(); 541 } 542 543 void CollectedHeap::resize_all_tlabs() { 544 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), 545 "Should only resize tlabs at safepoint"); 546 547 if (UseTLAB && ResizeTLAB) { 548 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { 549 thread->tlab().resize(); 550 } 551 } 552 } 553 554 jlong CollectedHeap::millis_since_last_whole_heap_examined() { 555 return (os::javaTimeNanos() - _last_whole_heap_examined_time_ns) / NANOSECS_PER_MILLISEC; 556 } 557 558 void CollectedHeap::record_whole_heap_examined_timestamp() { 559 _last_whole_heap_examined_time_ns = os::javaTimeNanos(); 560 } 561 562 void CollectedHeap::full_gc_dump(GCTimer* timer, bool before) { 563 assert(timer != nullptr, "timer is null"); 564 static uint count = 0; 565 if ((HeapDumpBeforeFullGC && before) || (HeapDumpAfterFullGC && !before)) { 566 if (FullGCHeapDumpLimit == 0 || count < FullGCHeapDumpLimit) { 567 GCTraceTime(Info, gc) tm(before ? "Heap Dump (before full gc)" : "Heap Dump (after full gc)", timer); 568 HeapDumper::dump_heap(); 569 count++; 570 } 571 } 572 573 LogTarget(Trace, gc, classhisto) lt; 574 if (lt.is_enabled()) { 575 GCTraceTime(Trace, gc, classhisto) tm(before ? "Class Histogram (before full gc)" : "Class Histogram (after full gc)", timer); 576 ResourceMark rm; 577 LogStream ls(lt); 578 VM_GC_HeapInspection inspector(&ls, false /* ! full gc */); 579 inspector.doit(); 580 } 581 } 582 583 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) { 584 full_gc_dump(timer, true); 585 } 586 587 void CollectedHeap::post_full_gc_dump(GCTimer* timer) { 588 full_gc_dump(timer, false); 589 } 590 591 void CollectedHeap::initialize_reserved_region(const ReservedHeapSpace& rs) { 592 // It is important to do this in a way such that concurrent readers can't 593 // temporarily think something is in the heap. (Seen this happen in asserts.) 594 _reserved.set_word_size(0); 595 _reserved.set_start((HeapWord*)rs.base()); 596 _reserved.set_end((HeapWord*)rs.end()); 597 } 598 599 void CollectedHeap::post_initialize() { 600 StringDedup::initialize(); 601 initialize_serviceability(); 602 } 603 604 #ifndef PRODUCT 605 606 bool CollectedHeap::promotion_should_fail(volatile size_t* count) { 607 // Access to count is not atomic; the value does not have to be exact. 608 if (PromotionFailureALot) { 609 const size_t gc_num = total_collections(); 610 const size_t elapsed_gcs = gc_num - _promotion_failure_alot_gc_number; 611 if (elapsed_gcs >= PromotionFailureALotInterval) { 612 // Test for unsigned arithmetic wrap-around. 613 if (++*count >= PromotionFailureALotCount) { 614 *count = 0; 615 return true; 616 } 617 } 618 } 619 return false; 620 } 621 622 bool CollectedHeap::promotion_should_fail() { 623 return promotion_should_fail(&_promotion_failure_alot_count); 624 } 625 626 void CollectedHeap::reset_promotion_should_fail(volatile size_t* count) { 627 if (PromotionFailureALot) { 628 _promotion_failure_alot_gc_number = total_collections(); 629 *count = 0; 630 } 631 } 632 633 void CollectedHeap::reset_promotion_should_fail() { 634 reset_promotion_should_fail(&_promotion_failure_alot_count); 635 } 636 637 #endif // #ifndef PRODUCT 638 639 // It's the caller's responsibility to ensure glitch-freedom 640 // (if required). 641 void CollectedHeap::update_capacity_and_used_at_gc() { 642 _capacity_at_last_gc = capacity(); 643 _used_at_last_gc = used(); 644 }