From 03f1e6a2aa8aa1d5aef79a33a243372a457f0fa2 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 29 Nov 2022 15:37:29 -0500 Subject: [PATCH] YJIT: Fix IseqPayload::pages memory bloat HashSet::clear() doesn't deallocate the backing buffer and shrink the capacity. Replace with a 0-capcity set instead so we reclaim some memory each code GC. --- yjit/src/asm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs index 417d664b07..47e2dca137 100644 --- a/yjit/src/asm/mod.rs +++ b/yjit/src/asm/mod.rs @@ -574,7 +574,7 @@ impl CodeBlock { }); // Avoid accumulating freed pages for future code GC for_each_off_stack_iseq_payload(|iseq_payload: &mut IseqPayload| { - iseq_payload.pages.clear(); + iseq_payload.pages = std::collections::HashSet::default(); }); // Outlined code generated by CodegenGlobals::init() should also be kept. for page in CodegenGlobals::get_ocb_pages() {