From cde4093dfb5d7eb72a0f912a4ca1df0bab4d2468 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Mon, 10 Nov 2025 03:04:49 +0000 Subject: [PATCH] Set count_live_bytes_in_gc option when print_fragmentation is enabled --- mmtk/src/api.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mmtk/src/api.rs b/mmtk/src/api.rs index 37002a7d..414a1607 100644 --- a/mmtk/src/api.rs +++ b/mmtk/src/api.rs @@ -101,6 +101,11 @@ pub extern "C" fn mmtk_gc_init( let success = builder.options.threads.set(n_gcthreads); assert!(success, "Failed to set GC threads to {}", n_gcthreads); } + + if cfg!(feature = "print_fragmentation") { + let success = builder.options.count_live_bytes_in_gc.set(true); + assert!(success, "Failed to enable live byte counting in GC"); + } } // Make sure that we haven't initialized MMTk (by accident) yet @@ -643,7 +648,7 @@ pub extern "C" fn get_mmtk_version() -> *const c_char { pub extern "C" fn print_fragmentation() { let map = memory_manager::live_bytes_in_last_gc(&SINGLETON); for (space, stats) in map { - println!( + eprintln!( "Utilization in space {:?}: {} live bytes, {} total bytes, {:.2} %", space, stats.live_bytes,