nobu.nokada / softhome.net writes: > Hi, > > At Wed, 13 Feb 2002 09:34:39 +0900, > Matt Armstrong <matt / lickey.com> wrote: >> If I run this script >> >> require 'tempfile' >> >> while true >> tempfile = nil >> begin >> tempfile = Tempfile.new('tempfile-test') >> ensure >> tempfile.close(true) unless tempfile.nil? >> end >> end >> >> From a shell in which I've done "ulimit -v 20480" the ruby interpreter >> seg faults. It seems to seg fault when it runs out of memory. > > Since GC is prohibited while compilation, temporary objects > remain. You can reduce the leak by calling GC.start sometimes > in loop. > > But eval has yet another leak, it's a known but pending bug > still. Should Ruby ever seg fault when it runs out of memory? That is the bug I'm most concerned about. I do not completely understand your answer -- what is "compilation" for Ruby? When is GC disabled in my program above? Hmm...I see that Tempfile uses SimpleDelegator which uses eval, so is that causing a leak? I did experiment with GC.start and it still quickly runs out of memory. I also found a possible leak with ObjectSpace.define_finalizer. I think the finalizer proc is never freed. I found that this program runs forever using about 5 megs: loop { string = "a" * 1024 } I found that this program runs forever using about 11 megs: finalize_proc = lambda { } loop { string = "a" ObjectSpace.define_finalizer(string, finalize_proc) } I find that this program chews up memory until it runs out (and the CVS version of ruby then seg faults): loop { string = "a" ObjectSpace.define_finalizer(string) { } } This happens in both 1.6 and 1.7. Since Tempfile uses a new proc for the finalizer of each new object, this is bad. -- matt