[ruby-core:104817] [Ruby master Bug#18065] 3.0.2 - possible memory leak in Hash#transform_keys!
From:
sean@...
Date:
2021-08-07 00:03:28 UTC
List:
ruby-core #104817
Issue #18065 has been reported by sean@duke.edu (Sean Dilda).
----------------------------------------
Bug #18065: 3.0.2 - possible memory leak in Hash#transform_keys!
https://bugs.ruby-lang.org/issues/18065
* Author: sean@duke.edu (Sean Dilda)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
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>