The original example is in [ruby-core:3456]

 Personnaly I've still a problem with 1.8 only and frame_dup()

 If it has a frame_dup(), it must have a frame_free() no ?

svg% cat b.rb
#!./ruby
def assert_raise(arg)
   yield
rescue
end

def tt
   Proc.new {}
   assert_raise(Errno::ENOENT) { yield }
end

def test_memory_leak
   system("ps aux | head -1")
   100000.times do |i|
      system("ps aux | grep ruby | grep -v grep | grep -v gdb") if i % 10000 == 0
      tt { raise Errno::ENOENT  }
   end
end

test_memory_leak

svg%
 
svg% ./ruby -v b.rb
ruby 1.8.2 (2004-10-23) [i686-linux]
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
ts       24852  0.0  0.5  2724 1340 pts/0    S    15:18   0:00 ./ruby -v b.rb
ts       24852  0.0  1.3  4772 3416 pts/0    S    15:18   0:00 ./ruby -v b.rb
ts       24852 99.9  1.9  6448 5092 pts/0    R    15:18   0:01 ./ruby -v b.rb
ts       24852 99.9  2.6  8200 6844 pts/0    S    15:18   0:02 ./ruby -v b.rb
ts       24852 96.0  3.3  9888 8532 pts/0    R    15:18   0:02 ./ruby -v b.rb
ts       24852 90.2  4.0 11600 10244 pts/0   S    15:18   0:03 ./ruby -v b.rb
ts       24852 99.9  4.7 13328 11972 pts/0   S    15:18   0:04 ./ruby -v b.rb
ts       24852 99.9  5.3 15016 13660 pts/0   S    15:18   0:05 ./ruby -v b.rb
ts       24852 96.8  6.0 16768 15412 pts/0   S    15:18   0:05 ./ruby -v b.rb
ts       24852 93.7  6.7 18460 17104 pts/0   S    15:18   0:06 ./ruby -v b.rb
svg% 

svg% diff -up eval.c.old eval.c
--- eval.c.old  2004-10-23 15:17:14.000000000 +0200
+++ eval.c      2004-10-23 15:18:32.000000000 +0200
@@ -7743,13 +7743,14 @@ blk_mark(data)
 }
 
 static void
-blk_free(data)
-    struct BLOCK *data;
-{
+frame_free(frame)
     struct FRAME *frame;
-    void *tmp;
+{
+    struct FRAME *tmp;
 
-    frame = data->frame.prev;
+    if (frame->argc > 0 && (frame->flags & FRAME_MALLOC))
+        free(frame->argv);
+    frame = frame->prev;
     while (frame) {
        if (frame->argc > 0 && (frame->flags & FRAME_MALLOC))
            free(frame->argv);
@@ -7757,9 +7758,16 @@ blk_free(data)
        frame = frame->prev;
        free(tmp);
     }
+}
+
+static void
+blk_free(data)
+    struct BLOCK *data;
+{
+    void *tmp;
+
     while (data) {
-       if (data->frame.argc > 0)
-           free(data->frame.argv);
+        frame_free(&data->frame);
        tmp = data;
        data = data->prev;
        free(tmp);
svg% 

svg% ./ruby -v b.rb
ruby 1.8.2 (2004-10-23) [i686-linux]
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
ts       25875  0.0  0.5  2732 1344 pts/0    S    15:21   0:00 ./ruby -v b.rb
ts       25875  0.0  0.7  3172 1812 pts/0    S    15:21   0:00 ./ruby -v b.rb
ts       25875 99.9  0.7  3172 1812 pts/0    S    15:21   0:01 ./ruby -v b.rb
ts       25875 82.0  0.7  3172 1812 pts/0    S    15:21   0:01 ./ruby -v b.rb
ts       25875 99.9  0.7  3172 1812 pts/0    S    15:21   0:02 ./ruby -v b.rb
ts       25875 91.3  0.7  3172 1812 pts/0    S    15:21   0:02 ./ruby -v b.rb
ts       25875 99.9  0.7  3172 1812 pts/0    S    15:21   0:03 ./ruby -v b.rb
ts       25875 96.0  0.7  3172 1812 pts/0    S    15:21   0:03 ./ruby -v b.rb
ts       25875 87.6  0.7  3172 1812 pts/0    S    15:21   0:04 ./ruby -v b.rb
ts       25875 99.0  0.7  3172 1812 pts/0    S    15:21   0:04 ./ruby -v b.rb
svg% 




Guy Decoux