# Memory release problem

**URL:** <https://www.ruby-forum.com/t/memory-release-problem/188924>\
**Category:** Rails\
**Created:** [May 20, 2010, 4:00pm UTC](https://www.ruby-forum.com/t/memory-release-problem/188924 "2010-05-20T16:00:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmanivannancse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jmanivannancse](https://www.ruby-forum.com/u/jmanivannancse)\
**Post date:** [May 20, 2010, 4:00pm UTC](https://www.ruby-forum.com/t/memory-release-problem/188924/1 "2010-05-20T16:00:47Z")

</div>

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/209794#new)  
[http://www.ruby-forum.com/topic/209796#new](http://www.ruby-forum.com/topic/209796#new)  
[http://www.ruby-forum.com/topic/209984#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
