Project

General

Profile

Actions

Bug #18065

closed

3.0.2 - possible memory leak in Hash#transform_keys!

Added by sean@duke.edu (Sean Dilda) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
[ruby-core:104817]

Description

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.

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0