From: "Jesús Gabriel y Galán" Date: 2010-09-25T16:28:05+09:00 Subject: Re: how do i force ruby to release memory On Sat, Sep 25, 2010 at 6:41 AM, Amit Tomar wrote: > Ryan Davis wrote: >> On Sep 24, 2010, at 01:58 , Amit Tomar wrote: >> >>> def downlaod >>> @stream = Stream.find(params[:id]) >> >> right there... you're creating an instance variable that is holding onto >> your Stream object. If that doesn't let go of the 1.1g it downloaded, >> then you'll hold onto it forever. > > but Ryan how do i force it to release memory??? Do you need the stream outside that method? If not, don't use an instance variable, and use a local variable instead. def download stream = Stream.find(params[:id]) ... end When the method finishes executing the stream variable goes out of scope, and it's the only reference to that object, so that memory can be freed by the GC. Jesus.