Project

General

Profile

Actions

Bug #9541

closed

Markedly increased Hash memory usage if Hash is cleared before reinsertion.

Added by hanke (Florian Hanke) about 10 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
Backport:
[ruby-core:60904]

Description

After a recent upgrade to Ruby 2.1.0 I noticed a significant increase in memory usage when using hashes of any size when clearing the hashes before inserting.

The compared versions are:
ruby 1.9.3dev (2011-09-23 revision 33323) [x86_64-darwin12.2.1]
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]

To test this behaviour I repeatedly (10x) filled in 1 million different string keys, each with a nil value.

Results:

  • With Ruby 1.9.3, RSS used stays mostly constant (to 157952 when clearing before inserting).
  • With Ruby 2.1.0, RSS used grows far more rapidly when the Hash is cleared before inserting (to 241972, mostly right after refilling for the first time), but also jumps up once when this is not done.

I've uploaded my measurements and test setup here:
https://gist.github.com/floere/9111529

My assumption is that the GC is not run at appropriate times due to more lax GC settings.

Note: I was not sure whether this is a bug or not. It does lead to a marked increase in memory usage for example on Heroku.

Actions

Also available in: Atom PDF

Like0
Like0