Do that a lot. Watch RAM vanish. GC cleans up the objects out of object space just fine, but RAM trickles away nonetheless.
Here is a test program:
loop do
attrs = Hash['this','that','the other','enough','stuff','for six']
Hash[attrs]
end
I have tested it on an installation of RedHat Enterprise Linux with 1.8.1, 1.8.2, 1.8.4, and 1.8.5 and also under 1.8.4 (one click installer) on WinXP Home.
I've ran it under valgrind and just straight, and have inserted code to run GC after each loop iteration. The behavior is consistent. If you eliminate the Hash[attrs] line, there is no leak.
On 8/28/06, khaines@enigo.com <khaines@enigo.com> wrote:
Make a hash:
h = {'a' => 1, 'b' => 2, 'c' => 3}
And make another out of it:
Hash[h]
Do that a lot. Watch RAM vanish. GC cleans up the objects out of object
space just fine, but RAM trickles away nonetheless.
Here is a test program:
loop do
attrs = Hash['this','that','the other','enough','stuff','for six']
Hash[attrs]
end
I have tested it on an installation of RedHat Enterprise Linux with 1.8.1,
1.8.2, 1.8.4, and 1.8.5 and also under 1.8.4 (one click installer) on
WinXP Home.
I've ran it under valgrind and just straight, and have inserted code to
run GC after each loop iteration. The behavior is consistent. If you
eliminate the Hash[attrs] line, there is no leak.
Wow...that seems to be a pretty major leak to have made it this long
w/o being noticed. Maybe that type of behavior isn't repeated often
enough in most programs to expose the leak?
- rob
···
On 8/28/06, khaines@enigo.com <khaines@enigo.com> wrote:
Make a hash:
h = {'a' => 1, 'b' => 2, 'c' => 3}
And make another out of it:
Hash[h]
Do that a lot. Watch RAM vanish. GC cleans up the objects out of object
space just fine, but RAM trickles away nonetheless.
Here is a test program:
loop do
attrs = Hash['this','that','the other','enough','stuff','for six']
Hash[attrs]
end
I have tested it on an installation of RedHat Enterprise Linux with 1.8.1,
1.8.2, 1.8.4, and 1.8.5 and also under 1.8.4 (one click installer) on
WinXP Home.
I've ran it under valgrind and just straight, and have inserted code to
run GC after each loop iteration. The behavior is consistent. If you
eliminate the Hash[attrs] line, there is no leak.
It's a small enough leak that it takes a lot of iterations to start to add up. And while the threshold of pain involved in chasing that thing down wasn't horrible, it's high enough that I can understand people doing what I have done for a long time:
Oh, that process is getting a bit big. *kill* *restart*
Or they assume that it's a bug in their code somewhere and do the same thing.
Look at the discussion about Mutex leaking last week.
BTW, my test code makes use of a number of mutexes and heavy use of threading, and after running 120k hits through it, the RAM usage is rock solid at 13.8Mb. Normally after that many hits it would have grown to around 45mb. So, this is very pleasing to me.
Kirk Haines
···
On Tue, 29 Aug 2006, Rob Sanheim wrote:
Wow...that seems to be a pretty major leak to have made it this long
w/o being noticed. Maybe that type of behavior isn't repeated often
enough in most programs to expose the leak?
+static VALUE hash_alloc0 _((VALUE));
static VALUE hash_alloc _((VALUE));
static VALUE
-hash_alloc(klass)
+hash_alloc0(klass)
VALUE klass;
{
@@ -233,9 +234,19 @@ hash_alloc(klass)
+static VALUE hash_alloc0 _((VALUE));
static VALUE hash_alloc _((VALUE));
static VALUE
-hash_alloc(klass)
+hash_alloc0(klass)
VALUE klass;
{
@@ -233,9 +234,19 @@ hash_alloc(klass)