diff --git a/src/policy/marksweepspace/malloc_ms/global.rs b/src/policy/marksweepspace/malloc_ms/global.rs index dd1f91042c..7327d80d67 100644 --- a/src/policy/marksweepspace/malloc_ms/global.rs +++ b/src/policy/marksweepspace/malloc_ms/global.rs @@ -274,6 +274,11 @@ impl MallocSpace { } pub fn new(args: crate::policy::space::PlanCreateSpaceArgs) -> Self { + if *args.options.count_live_bytes_in_gc { + // The implementation of counting live bytes needs a SpaceDescriptor which we do not have for MallocSpace. + // Besides we cannot meaningfully measure the live bytes vs total pages for MallocSpace. + panic!("count_live_bytes_in_gc is not supported by MallocSpace"); + } MallocSpace { phantom: PhantomData, active_bytes: AtomicUsize::new(0), diff --git a/src/scheduler/gc_work.rs b/src/scheduler/gc_work.rs index ceae37d514..28d04c6874 100644 --- a/src/scheduler/gc_work.rs +++ b/src/scheduler/gc_work.rs @@ -154,12 +154,14 @@ impl GCWork for Release { debug_assert!(result.is_ok()); } - let live_bytes = mmtk - .scheduler - .worker_group - .get_and_clear_worker_live_bytes(); - *mmtk.state.live_bytes_in_last_gc.borrow_mut() = - mmtk.aggregate_live_bytes_in_last_gc(live_bytes); + if *mmtk.get_options().count_live_bytes_in_gc { + let live_bytes = mmtk + .scheduler + .worker_group + .get_and_clear_worker_live_bytes(); + *mmtk.state.live_bytes_in_last_gc.borrow_mut() = + mmtk.aggregate_live_bytes_in_last_gc(live_bytes); + } } }