From: "alanwu (Alan Wu) via ruby-core" Date: 2026-11-21T00:20:17+00:00 Subject: [ruby-core:127649] [Ruby Feature#22613] iseq freeing after require/load without reference Issue #22613 has been updated by alanwu (Alan Wu). Good idea to save memory. Though, freeing at a certain program point by taking a ractor barrier is incorrect. That does not prevent you from freeing code that some other ractor is still running. Like trying to free JIT code, only the GC can prove that an iseq is truly unreachable. It's much cleaner to reorganize the object graph rather than trying to do it by guessing a program point with sprinkles of adhoc checks like iseq_run_once_releasable_p(). It should be robust enough to not require adding a feature flag. ---------------------------------------- Feature #22613: iseq freeing after require/load without reference https://bugs.ruby-lang.org/issues/22613#change-120167 * Author: fuzzyrichie-gusto (Richard Desmarais) * Status: Open ---------------------------------------- When Ruby loads a file, it compiles the code into bytecode. The code at the top of each file and inside class bodies only ever runs once - while the file loads. Today Ruby keeps that one-time bytecode in memory forever, because a single block created inside a class (like a sig { } or a scope -> { }) keeps the whole file's compiled code alive. The change frees that bytecode right after each file finishes loading, keeping only the small bits that surviving blocks still need, which cuts memory for compiled code by about 40% in our app. This would be an opt-in feature - not a default. That being said, if the value is there to keep it, that's fine too - this just lets those who want the memory win to apply it. https://github.com/ruby/ruby/pull/20059 is the PR. I'm going to run it with a build as default-on to see what fails - which will help me fix any issues that arise - but will then put it back to opt-in. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/