Proc#to_sexp leaks memory

3 views
Skip to first unread message

Sharon Rosner

unread,
Feb 16, 2008, 4:20:00 AM2/16/08
to ambition.rb
Hi all

I just found out that the ruby2ruby of Proc#to_sexp leaks memory, and
browsing the ambition source code t looks the ambition implementation
of the same method will also leak memory because methods are being
added to the ProcHolder class but are never removed. In Sequel we have
a different implementation that might be a little slower (though I
didn't run any benchmarks) but nevertheless removes the memory leak:

class Proc
def to_sexp
block = self
c = Class.new {define_method(:m, &block)}
body = ParseTree.translate(c, :m)[2][1..-1]
[:proc, *body]
end
end

I couldn't find anywhere to open a ticket, so I'm reporting it here
FYI.

best
sharon

Chris Wanstrath

unread,
Feb 16, 2008, 4:36:38 AM2/16/08
to ambit...@googlegroups.com

The Ambition implementation doesn't leak memory. The ruby2ruby leak
was discovered and fixed before the first gem release.

- Chris

Reply all
Reply to author
Forward
0 new messages