Hi,

Thanks for your replies. I've modified the code a little so that my
string "hello" is not the last statement. And also, it is used in
"puts". Even when it's out of scope, it's not being free.

http://pastie.caboo.se/50041

Jason : Why I'm doin this, frankly speaking, the concept of memory
leaks in ruby code is still not very clear to me. I came across
http://scottstuff.net/blog/articles/2006/08/17/memory-leak-profiling-with-rails
- which checks for common objects within 10 seconds interval. So I
wrote a lil piece of code myself to see if any objects created in a
method call, are getting removed or not when it's out of scope.

I'd like to see if someone can point me to an example of memory leak
in ruby code. Or lemme know how to detect proper memory leaks.

Thanks!
Pratik

On 3/27/07, Rick DeNatale <rick.denatale / gmail.com> wrote:
> On 3/27/07, Jason Roelofs <jameskilton / gmail.com> wrote:
> > So my first question is this: why are you doing this? Ruby's garbage
> > collector is perfectly capable of finding and preventing REAL memory leaks.
> >
> > What you have here is not a memory leak detector, but an "objects have been
> > created" detector. "hello" is then obviously caught as a new object created,
> > and as Ruby returns the result of the last statement of a method, it is not
> > yet out of scope until the program quits, in your case.
>
> There's also the problem that he's trying to detect surviving objects
> by comparing object_ids before and after GC, there's no guarantee that
> an object_id of a gc'd object won't be reused. Object_id's only need
> to be unique among LIVE objects.
>
> --
> Rick DeNatale
>
> My blog on Ruby
> http://talklikeaduck.denhaven2.com/
>
>


-- 
rm -rf / 2>/dev/null - http://null.in

Dont judge those who try and fail, judge those who fail to try..