Initializing and destroying(?) instance variables


I finished writing a fairly large Ruby application and I was careless
with cleaning up variables. My objects contain references to large
ActiveRecord objects (instance variables), and I wanted to make sure
that I don’t specifically need to set these instance variables to nil
when they’re not used anymore: as long as I set the parent object to
nil, since there will be no reference to its instance variables, the
parent object and its instance variables (objects) should be removed
by the GC. Is this correct?

For example, I might have this program:

class Blah

attr_accessor :arr

def initialize
@arr =, ‘TEST’)


while (true)
b =
sleep 5

I noticed that the memory on my machine only goes up at the beginning
of the program, and then stays constant. I can only conclude that each
time the loop executes, the old b.arr becomes unreferenced and is
garbage collected and that the new b.arr is allocated (thus memory
usage is the same).
I just need someone to confirm this, since my program freezes after
running more than 24hours and I can’t find the (memory) leakage.