From: "Jesús Gabriel y Galán" Date: 2010-09-26T17:00:26+09:00 Subject: Re: how do i force ruby to release memory On Sun, Sep 26, 2010 at 9:53 AM, Ryan Davis wrote: > > On Sep 25, 2010, at 22:44 , Amit Tomar wrote: > >> i don't want stream outside this method. >> and what you want to say as soon as method finishes it automatically >> release >> memmory (since stream scope is only within the function) >> am i right?? > > no. that's not how a GC'd environment (usually) works. You can force the GC to run by telling it to (`ri GC` for more info), but even that won't guarantee your memory gets reclaimed by the system (or at all, since ruby uses a conservative GC there is no guarantee at all), as others have said in this thread. But that's usually the best you can (or should) do: check the objects that you don't really want anymore, and remove any reference to them. After that, as Ryan says, there are no or little guarantees about when or if the object would be removed. Jesus.