Issue #18065 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE

ruby_3_0 d6b8b37a2608a0fbb8bcfd10356bb25f9ebbe1fe merged revision(s) e5dd40b1f3a11f48d566413ab347ce0cfdd94960.

----------------------------------------
Bug #18065: 3.0.2 - possible memory leak in Hash#transform_keys!
https://bugs.ruby-lang.org/issues/18065#change-93175

* Author: sean / duke.edu (Sean Dilda)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
* Backport: 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE
----------------------------------------
I found what may be a memory leak in Hash#transform_keys! in version 3.0.2


This sample code will reproduce the issue.  It quickly consumes gigabytes of memory when running on 3.0.2, but has very normal memory usage on 3.0.1.  I tested using the ruby:3.0.2 docker image.

```ruby
h = { value1: 1, value2: 2 }
loop { h.transform_keys!(&:to_s) }
```

The issue doesn't appear if there is only one key in the hash.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>