[ruby-core:125071] [Ruby Feature#21957] Introduce `Enumerable#close` to free internal resources.
Issue #21957 has been reported by ioquatix (Samuel Williams). ---------------------------------------- Feature #21957: Introduce `Enumerable#close` to free internal resources. https://bugs.ruby-lang.org/issues/21957 * Author: ioquatix (Samuel Williams) * Status: Open * Assignee: ioquatix (Samuel Williams) ---------------------------------------- In some cases, `Enumerable` has substantial internal state (e.g. Fiber) related to enumeration. There is currently no way to clear up this state besides garbage collection, which means that we can accumulate considerable garbage before cleaning up, even if we know when the enumerable is no longer needed. I'd like to introduce `Enumerable#close` which invalidates the enumerable, freeing internal resources. After which, most usage would result in `Enumerable::ClosedError`. -- https://bugs.ruby-lang.org/
Issue #21957 has been updated by Eregon (Benoit Daloze). +1 Leaking Fibers through an Enumerator is quite common and relying on the GC to clean that up is pretty brittle and it also adds significant complexity on the Ruby implementation (e.g. weakref to the Fiber object). You're mentioning `Enumerable` here, but isn't it about `Enumerator` rather? ioquatix (Samuel Williams) wrote:
After which, most usage would result in `Enumerable::ClosedError`.
Right, and that would work by simply having `Enumerator#each` for such Enumerators raise a `Enumerator::ClosedError`. ---------------------------------------- Feature #21957: Introduce `Enumerable#close` to free internal resources. https://bugs.ruby-lang.org/issues/21957#change-116777 * Author: ioquatix (Samuel Williams) * Status: Open * Assignee: ioquatix (Samuel Williams) ---------------------------------------- In some cases, `Enumerable` has substantial internal state (e.g. Fiber) related to enumeration. There is currently no way to clear up this state besides garbage collection, which means that we can accumulate considerable garbage before cleaning up, even if we know when the enumerable is no longer needed. I'd like to introduce `Enumerable#close` which invalidates the enumerable, freeing internal resources. After which, most usage would result in `Enumerable::ClosedError`. -- https://bugs.ruby-lang.org/
participants (2)
-
Eregon (Benoit Daloze) -
ioquatix (Samuel Williams)