------art_42600_3055466.1175132370854
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Pratik, the only real memory leaks you will see in a Ruby program is when a
program keeps a hold of data indefinitely. This usually manifests itself in
long running programs with caches or when it just needs to keep info in
memory. When you're dealing with programs that run for days, weeks, or
months at a time, no matter what language you are in you need to be very
careful what objects are kept around and for how long.

Otherwise, it's just spilt milk.

Jason

On 3/28/07, Pratik <pratiknaik / gmail.com> wrote:
>
> 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..
>
>

------art_42600_3055466.1175132370854--