# Memory issues

**URL:** <https://www.ruby-forum.com/t/memory-issues/188598>\
**Category:** Rails\
**Created:** [May 14, 2010, 5:10pm UTC](https://www.ruby-forum.com/t/memory-issues/188598 "2010-05-14T17:10:38Z")\
**Posts on this page:** 4\
**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 14, 2010, 5:10pm UTC](https://www.ruby-forum.com/t/memory-issues/188598/1 "2010-05-14T17:10:38Z")

</div>

Hi,

I am really struggle with following result…i have to explain my  
situation.  
First, i have created small rails application which is only used to show  
data from table called products(nearly 11 lakhs of records in the  
table).Application was getting very low performance, So i decided to  
measure Rails’s memory usage.

This was my memory usage before run application:  
root@dev:free -m  
total used free shared buffers  
cached  
Mem: 1000 854 146 0 13  
177  
-/+ buffers/cache: 662 646  
Swap: 1223 48 1223

I then proceeded to hit first request,free memory was reduced from 646MB  
to 362MB.  
root@dev:free -m  
total used free shared buffers  
cached  
Mem: 1000 854 146 0 13  
177  
-/+ buffers/cache: 662 362  
Swap: 1223 48 1223

When i continuously used application,free memory was reducing gradually

Used memory is not released even after the report shows result.

Free memory didn’t come back to initial level like 646MB even i stopped  
to use my application nearly 20 min…

Please give me a solution to solve this problem…

Thanks

---

<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 14, 2010, 5:22pm UTC](https://www.ruby-forum.com/t/memory-issues/188598/2 "2010-05-14T17:22:12Z")

</div>

Google for “linux free command”

From the third link: [http://salomie.ro/wiki/index.php/Linux\_Free\_Command](http://salomie.ro/wiki/index.php/Linux_Free_Command)

“The second line starting with -/+ buffers/cache: tells us how much of  
the memory in the buffers/cache is used by the applications and how  
much is free. Keep in mind that in general the cache is filled with  
disk IO cached data. The cache can be very easily reclaimed by the OS  
for applications. Let BUFFERS + CACHED from first line be value X.”

It’s using caches, and my guess is that if stopping the app doesn’t  
free it, then the caching is happening at the OS/FS level, not in Ruby  
or Rails.

Larry

---

<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 14, 2010, 5:41pm UTC](https://www.ruby-forum.com/t/memory-issues/188598/3 "2010-05-14T17:41:59Z")

</div>

Larry Meadors wrote:

> Google for “linux free command”
> 
> From the third link: [http://salomie.ro/wiki/index.php/Linux\_Free\_Command](http://salomie.ro/wiki/index.php/Linux_Free_Command)
> 
> “The second line starting with -/+ buffers/cache: tells us how much of  
> the memory in the buffers/cache is used by the applications and how  
> much is free. Keep in mind that in general the cache is filled with  
> disk IO cached data. The cache can be very easily reclaimed by the OS  
> for applications. Let BUFFERS + CACHED from first line be value X.”
> 
> It’s using caches, and my guess is that if stopping the app doesn’t  
> free it, then the caching is happening at the OS/FS level, not in Ruby  
> or Rails.
> 
> Larry

Thanks for reply…  
Here used memory is released when i stop server…

---

<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 15, 2010, 7:07am UTC](https://www.ruby-forum.com/t/memory-issues/188598/4 "2010-05-15T07:07:50Z")

</div>

Larry Meadors wrote:

> Google for “linux free command”
> 
> From the third link: [http://salomie.ro/wiki/index.php/Linux\_Free\_Command](http://salomie.ro/wiki/index.php/Linux_Free_Command)
> 
> “The second line starting with -/+ buffers/cache: tells us how much of  
> the memory in the buffers/cache is used by the applications and how  
> much is free. Keep in mind that in general the cache is filled with  
> disk IO cached data. The cache can be very easily reclaimed by the OS  
> for applications. Let BUFFERS + CACHED from first line be value X.”
> 
> It’s using caches, and my guess is that if stopping the app doesn’t  
> free it, then the caching is happening at the OS/FS level, not in Ruby  
> or Rails.
> 
> Larry

Larry,  
In my app,the memory is freed when i stop the server.Can you tell how  
can i freed the used memory after the execution of the query and results  
are shown in browser
