Bug #5058
closedMemory leak in Psych.load
Description
=begin
I believe there's a memory leak in (({Psych.load})) that affects all long running processes that loads YAML a large number of times.
The expected behaviour is that the memory consumption doesn't grow just because a very simple piece of YAML is loaded and immediately thrown away multiple times.
The easiest way to reproduce it is by executing the following piece of code in irb and look at the memory consumption of the process in a process monitor.
require 'psych'
(1..10000).each {|i| Psych.load "---\nhey\n...\n"}
The two pictures I've attached show what it looks like in my process monitor before and after.
I've run this on Mac OS X 10.6.8.
The compiler is: (({i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)}))
And I've used no ./configure options.
=end
Files
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
The leaks are fixed on trunk, but the commits have not been ported back to the 1.9.2 branch:
http://redmine.ruby-lang.org/issues/4832
If you install and use the gem until the backport is applied, that should fix the problem:
gem 'psych', '~> 1.2.0'
require 'psych'
loop do
Psych.load "---\nhey\n...\n"
end
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
- Status changed from Open to Rejected