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 if (!Metaspace::contains(object->klass_without_asserts())) { 233 return false; 234 } 235 236 return true; 237 } 238 239 // Memory state functions. 240 241 242 CollectedHeap::CollectedHeap() : 243 _capacity_at_last_gc(0), 244 _used_at_last_gc(0), 245 _soft_ref_policy(), 246 _is_stw_gc_active(false), 247 _last_whole_heap_examined_time_ns(os::javaTimeNanos()), 248 _total_collections(0), 249 _total_full_collections(0), 250 _gc_cause(GCCause::_no_gc), 251 _gc_lastcause(GCCause::_no_gc) 252 { 253 // If the minimum object size is greater than MinObjAlignment, we can 254 // end up with a shard at the end of the buffer that's smaller than 255 // the smallest object. We can't allow that because the buffer must 256 // look like it's full of objects when we retire it, so we make 257 // sure we have enough space for a filler int array object. 258 size_t min_size = min_dummy_object_size(); 259 _lab_alignment_reserve = min_size > (size_t)MinObjAlignment ? align_object_size(min_size) : 0; 260 261 const size_t max_len = size_t(arrayOopDesc::max_array_length(T_INT)); 262 const size_t elements_per_word = HeapWordSize / sizeof(jint); 263 _filler_array_max_size = align_object_size(filler_array_hdr_size() + 264 max_len / elements_per_word); 265 266 NOT_PRODUCT(_promotion_failure_alot_count = 0;) 267 NOT_PRODUCT(_promotion_failure_alot_gc_number = 0;) 268 269 if (UsePerfData) { 270 EXCEPTION_MARK; 271 272 // create the gc cause jvmstat counters 273 _perf_gc_cause = PerfDataManager::create_string_variable(SUN_GC, "cause", 274 80, GCCause::to_string(_gc_cause), CHECK); 275 276 _perf_gc_lastcause = 277 PerfDataManager::create_string_variable(SUN_GC, "lastCause", 278 80, GCCause::to_string(_gc_lastcause), CHECK); 279 } 280 281 // Create the ring log 282 if (LogEvents) { 283 _gc_heap_log = new GCHeapLog(); 284 } else { 285 _gc_heap_log = nullptr; 286 } 287 } 288 289 // This interface assumes that it's being called by the 290 // vm thread. It collects the heap assuming that the 291 // heap lock is already held and that we are executing in 292 // the context of the vm thread. 293 void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) { 294 Thread* thread = Thread::current(); 295 assert(thread->is_VM_thread(), "Precondition#1"); 296 assert(Heap_lock->is_locked(), "Precondition#2"); 297 GCCauseSetter gcs(this, cause); 298 switch (cause) { 299 case GCCause::_codecache_GC_threshold: 300 case GCCause::_codecache_GC_aggressive: 301 case GCCause::_heap_inspection: 302 case GCCause::_heap_dump: 303 case GCCause::_metadata_GC_threshold: { 304 HandleMark hm(thread); 305 do_full_collection(false); // don't clear all soft refs 306 break; 307 } 308 case GCCause::_metadata_GC_clear_soft_refs: { 309 HandleMark hm(thread); 310 do_full_collection(true); // do clear all soft refs 311 break; 312 } 313 default: 314 ShouldNotReachHere(); // Unexpected use of this function 315 } 316 } 317 318 MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, 319 size_t word_size, 320 Metaspace::MetadataType mdtype) { 321 uint loop_count = 0; 322 uint gc_count = 0; 323 uint full_gc_count = 0; 324 325 assert(!Heap_lock->owned_by_self(), "Should not be holding the Heap_lock"); 326 327 do { 328 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); 329 if (result != nullptr) { 330 return result; 331 } 332 333 if (GCLocker::is_active_and_needs_gc()) { 334 // If the GCLocker is active, just expand and allocate. 335 // If that does not succeed, wait if this thread is not 336 // in a critical section itself. 337 result = loader_data->metaspace_non_null()->expand_and_allocate(word_size, mdtype); 338 if (result != nullptr) { 339 return result; 340 } 341 JavaThread* jthr = JavaThread::current(); 342 if (!jthr->in_critical()) { 343 // Wait for JNI critical section to be exited 344 GCLocker::stall_until_clear(); 345 // The GC invoked by the last thread leaving the critical 346 // section will be a young collection and a full collection 347 // is (currently) needed for unloading classes so continue 348 // to the next iteration to get a full GC. 349 continue; 350 } else { 351 if (CheckJNICalls) { 352 fatal("Possible deadlock due to allocating while" 353 " in jni critical section"); 354 } 355 return nullptr; 356 } 357 } 358 359 { // Need lock to get self consistent gc_count's 360 MutexLocker ml(Heap_lock); 361 gc_count = Universe::heap()->total_collections(); 362 full_gc_count = Universe::heap()->total_full_collections(); 363 } 364 365 // Generate a VM operation 366 VM_CollectForMetadataAllocation op(loader_data, 367 word_size, 368 mdtype, 369 gc_count, 370 full_gc_count, 371 GCCause::_metadata_GC_threshold); 372 VMThread::execute(&op); 373 374 // If GC was locked out, try again. Check before checking success because the 375 // prologue could have succeeded and the GC still have been locked out. 376 if (op.gc_locked()) { 377 continue; 378 } 379 380 if (op.prologue_succeeded()) { 381 return op.result(); 382 } 383 loop_count++; 384 if ((QueuedAllocationWarningCount > 0) && 385 (loop_count % QueuedAllocationWarningCount == 0)) { 386 log_warning(gc, ergo)("satisfy_failed_metadata_allocation() retries %d times," 387 " size=" SIZE_FORMAT, loop_count, word_size); 388 } 389 } while (true); // Until a GC is done 390 } 391 392 MemoryUsage CollectedHeap::memory_usage() { 393 return MemoryUsage(InitialHeapSize, used(), capacity(), max_capacity()); 394 } 395 396 void CollectedHeap::set_gc_cause(GCCause::Cause v) { 397 if (UsePerfData) { 398 _gc_lastcause = _gc_cause; 399 _perf_gc_lastcause->set_value(GCCause::to_string(_gc_lastcause)); 400 _perf_gc_cause->set_value(GCCause::to_string(v)); 401 } 402 _gc_cause = v; 403 } 404 405 // Returns the header size in words aligned to the requirements of the 406 // array object type. 407 static int int_array_header_size() { 408 size_t typesize_in_bytes = arrayOopDesc::header_size_in_bytes(); 409 return (int)align_up(typesize_in_bytes, HeapWordSize)/HeapWordSize; 410 } 411 412 size_t CollectedHeap::max_tlab_size() const { 413 // TLABs can't be bigger than we can fill with a int[Integer.MAX_VALUE]. 414 // This restriction could be removed by enabling filling with multiple arrays. 415 // If we compute that the reasonable way as 416 // header_size + ((sizeof(jint) * max_jint) / HeapWordSize) 417 // we'll overflow on the multiply, so we do the divide first. 418 // We actually lose a little by dividing first, 419 // but that just makes the TLAB somewhat smaller than the biggest array, 420 // which is fine, since we'll be able to fill that. 421 size_t max_int_size = int_array_header_size() + 422 sizeof(jint) * 423 ((juint) max_jint / (size_t) HeapWordSize); 424 return align_down(max_int_size, MinObjAlignment); 425 } 426 427 size_t CollectedHeap::filler_array_hdr_size() { 428 return align_object_offset(int_array_header_size()); // align to Long 429 } 430 431 size_t CollectedHeap::filler_array_min_size() { 432 return align_object_size(filler_array_hdr_size()); // align to MinObjAlignment 433 } 434 435 void CollectedHeap::zap_filler_array_with(HeapWord* start, size_t words, juint value) { 436 Copy::fill_to_words(start + filler_array_hdr_size(), 437 words - filler_array_hdr_size(), value); 438 } 439 440 #ifdef ASSERT 441 void CollectedHeap::fill_args_check(HeapWord* start, size_t words) 442 { 443 assert(words >= min_fill_size(), "too small to fill"); 444 assert(is_object_aligned(words), "unaligned size"); 445 } 446 447 void CollectedHeap::zap_filler_array(HeapWord* start, size_t words, bool zap) 448 { 449 if (ZapFillerObjects && zap) { 450 zap_filler_array_with(start, words, 0XDEAFBABE); 451 } 452 } 453 #endif // ASSERT 454 455 void 456 CollectedHeap::fill_with_array(HeapWord* start, size_t words, bool zap) 457 { 458 assert(words >= filler_array_min_size(), "too small for an array"); 459 assert(words <= filler_array_max_size(), "too big for a single object"); 460 461 const size_t payload_size = words - filler_array_hdr_size(); 462 const size_t len = payload_size * HeapWordSize / sizeof(jint); 463 assert((int)len >= 0, "size too large " SIZE_FORMAT " becomes %d", words, (int)len); 464 465 ObjArrayAllocator allocator(Universe::fillerArrayKlass(), words, (int)len, /* do_zero */ false); 466 allocator.initialize(start); 467 if (CDSConfig::is_dumping_heap()) { 468 // This array is written into the CDS archive. Make sure it 469 // has deterministic contents. 470 zap_filler_array_with(start, words, 0); 471 } else { 472 DEBUG_ONLY(zap_filler_array(start, words, zap);) 473 } 474 } 475 476 void 477 CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap) 478 { 479 assert(words <= filler_array_max_size(), "too big for a single object"); 480 481 if (words >= filler_array_min_size()) { 482 fill_with_array(start, words, zap); 483 } else if (words > 0) { 484 assert(words == min_fill_size(), "unaligned size"); 485 ObjAllocator allocator(CollectedHeap::filler_object_klass(), words); 486 allocator.initialize(start); 487 } 488 } 489 490 void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap) 491 { 492 DEBUG_ONLY(fill_args_check(start, words);) 493 HandleMark hm(Thread::current()); // Free handles before leaving. 494 fill_with_object_impl(start, words, zap); 495 } 496 497 void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap) 498 { 499 DEBUG_ONLY(fill_args_check(start, words);) 500 HandleMark hm(Thread::current()); // Free handles before leaving. 501 502 // Multiple objects may be required depending on the filler array maximum size. Fill 503 // the range up to that with objects that are filler_array_max_size sized. The 504 // remainder is filled with a single object. 505 const size_t min = min_fill_size(); 506 const size_t max = filler_array_max_size(); 507 while (words > max) { 508 const size_t cur = (words - max) >= min ? max : max - min; 509 fill_with_array(start, cur, zap); 510 start += cur; 511 words -= cur; 512 } 513 514 fill_with_object_impl(start, words, zap); 515 } 516 517 void CollectedHeap::fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap) { 518 CollectedHeap::fill_with_object(start, end, zap); 519 } 520 521 void CollectedHeap::ensure_parsability(bool retire_tlabs) { 522 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), 523 "Should only be called at a safepoint or at start-up"); 524 525 ThreadLocalAllocStats stats; 526 527 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next();) { 528 BarrierSet::barrier_set()->make_parsable(thread); 529 if (UseTLAB) { 530 if (retire_tlabs) { 531 thread->tlab().retire(&stats); 532 } else { 533 thread->tlab().make_parsable(); 534 } 535 } 536 } 537 538 stats.publish(); 539 } 540 541 void CollectedHeap::resize_all_tlabs() { 542 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), 543 "Should only resize tlabs at safepoint"); 544 545 if (UseTLAB && ResizeTLAB) { 546 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { 547 thread->tlab().resize(); 548 } 549 } 550 } 551 552 jlong CollectedHeap::millis_since_last_whole_heap_examined() { 553 return (os::javaTimeNanos() - _last_whole_heap_examined_time_ns) / NANOSECS_PER_MILLISEC; 554 } 555 556 void CollectedHeap::record_whole_heap_examined_timestamp() { 557 _last_whole_heap_examined_time_ns = os::javaTimeNanos(); 558 } 559 560 void CollectedHeap::full_gc_dump(GCTimer* timer, bool before) { 561 assert(timer != nullptr, "timer is null"); 562 static uint count = 0; 563 if ((HeapDumpBeforeFullGC && before) || (HeapDumpAfterFullGC && !before)) { 564 if (FullGCHeapDumpLimit == 0 || count < FullGCHeapDumpLimit) { 565 GCTraceTime(Info, gc) tm(before ? "Heap Dump (before full gc)" : "Heap Dump (after full gc)", timer); 566 HeapDumper::dump_heap(); 567 count++; 568 } 569 } 570 571 LogTarget(Trace, gc, classhisto) lt; 572 if (lt.is_enabled()) { 573 GCTraceTime(Trace, gc, classhisto) tm(before ? "Class Histogram (before full gc)" : "Class Histogram (after full gc)", timer); 574 ResourceMark rm; 575 LogStream ls(lt); 576 VM_GC_HeapInspection inspector(&ls, false /* ! full gc */); 577 inspector.doit(); 578 } 579 } 580 581 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) { 582 full_gc_dump(timer, true); 583 } 584 585 void CollectedHeap::post_full_gc_dump(GCTimer* timer) { 586 full_gc_dump(timer, false); 587 } 588 589 void CollectedHeap::initialize_reserved_region(const ReservedHeapSpace& rs) { 590 // It is important to do this in a way such that concurrent readers can't 591 // temporarily think something is in the heap. (Seen this happen in asserts.) 592 _reserved.set_word_size(0); 593 _reserved.set_start((HeapWord*)rs.base()); 594 _reserved.set_end((HeapWord*)rs.end()); 595 } 596 597 void CollectedHeap::post_initialize() { 598 StringDedup::initialize(); 599 initialize_serviceability(); 600 } 601 602 #ifndef PRODUCT 603 604 bool CollectedHeap::promotion_should_fail(volatile size_t* count) { 605 // Access to count is not atomic; the value does not have to be exact. 606 if (PromotionFailureALot) { 607 const size_t gc_num = total_collections(); 608 const size_t elapsed_gcs = gc_num - _promotion_failure_alot_gc_number; 609 if (elapsed_gcs >= PromotionFailureALotInterval) { 610 // Test for unsigned arithmetic wrap-around. 611 if (++*count >= PromotionFailureALotCount) { 612 *count = 0; 613 return true; 614 } 615 } 616 } 617 return false; 618 } 619 620 bool CollectedHeap::promotion_should_fail() { 621 return promotion_should_fail(&_promotion_failure_alot_count); 622 } 623 624 void CollectedHeap::reset_promotion_should_fail(volatile size_t* count) { 625 if (PromotionFailureALot) { 626 _promotion_failure_alot_gc_number = total_collections(); 627 *count = 0; 628 } 629 } 630 631 void CollectedHeap::reset_promotion_should_fail() { 632 reset_promotion_should_fail(&_promotion_failure_alot_count); 633 } 634 635 #endif // #ifndef PRODUCT 636 637 // It's the caller's responsibility to ensure glitch-freedom 638 // (if required). 639 void CollectedHeap::update_capacity_and_used_at_gc() { 640 _capacity_at_last_gc = capacity(); 641 _used_at_last_gc = used(); 642 }