Memory release problem

In my application, i have Memory leak problem ie query's execution's
used memory is not released after executing the query.
i have already posted my problem
http://www.ruby-forum.com/topic/209794#new
http://www.ruby-forum.com/topic/209796#new
http://www.ruby-forum.com/topic/209984#new

when i use AR.connection.execute instead of ActiveRecord then i got a
temporarily solution as like

      @result = OfftakeReportingTable.connection.execute("select * from
offtake_reporting_tables limit 100000")
      @result.close

Here used memory is released.No problem
but memory is not released if i copied record to another variable like

@result = OfftakeReportingTable.connection.execute("select * from
offtake_reporting_tables limit 100000")
      z=[]
      for a in @result
        z << a
      end
      @result.close
      z.clear

please give me some ideas to release memory in above problem

Note:
         I used to track free memory and used memory by 'free -m'
command