logger icon indicating copy to clipboard operation
logger copied to clipboard

Use ObjectSpace::WeakKeyMap for level_override

Open nevans opened this issue 2 months ago • 0 comments

This allows fiber keys to be GCed and removed from the map. Otherwise, fibers that call #with_level create a memory leak if they are abandoned without running their ensure blocks.

Please note that Thread#kill is not the only way for a Fiber to be abandoned without running its ensure block. It's as simple as to_enum(:method_that_calls_with_level).next.


This is related to @byroot's comment here: https://github.com/ruby/logger/pull/132#discussion_r2393892976

nevans avatar Oct 01 '25 15:10 nevans