I've already called GC.start and yet some objects are not being freed. However, I'm still uncertain about memory leaks in ruby code and looking for an example of any such case. Thanks, Pratik On 3/28/07, Brian Candler <B.Candler / pobox.com> wrote: > On Wed, Mar 28, 2007 at 07:46:43PM +0900, Pratik wrote: > > 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. > > Objects are not freed when they go out of scope. Objects are freed when the > garbage collector runs, and notices that no outside references point to > these objects. (This is "mark and sweep garbage collection") > > You can force this to happen using GC.start, if you wish to play around with > the internals. > > Doing it other ways (e.g. reference counting) is expensive and error-prone. > I have a vague recollection that Python does it this way though. > > -- rm -rf / 2>/dev/null - http://null.in Dont judge those who try and fail, judge those who fail to try..