linux eats all memory, seems like it is not for specific application [duplicate]

The system is not overloaded and there is no huge process that eats memory (RAM) but still it has only 20-40 MB free.

Who is taking RAM and should I avoid it? (how?)


Solution 1:

See: http://www.linuxatemyram.com

See also: http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html

Solution 2:

Linux considers free RAM a waste of resources. Any memory not being used to store a program is used as buffer space to cache recent disk activity etc. It will flush the buffers to disk to make space as required for program memory allocation needs.

Solution 3:

The 'free' command will show you buffers and cache. The line that starts with -/+ buffers/cache shows the amount of really used and free memory with the buffers and cache subtracted.

             total       used       free     shared    buffers     cached
Mem:           373        350         23          0        135        109
-/+ buffers/cache:        105        268
Swap:          511          0        511

Notice that:

  • this machine has 373MB of RAM, of which 350MB is use, leaving 23MB memory free
  • that 350MB includes 135MB of buffers and 109MB of cache
  • when we subtract those buffers and cache amounts, only 105MB is actually used, leaving 268MB of memory free

The moment it is needed, cache is dropped and buffers are flushed to free memory. This provides very little overhead when the memory the moment the memory needs to be freed and provides significant performance increase as long as the memory can be used as buffers / cache.

So, if you want to know the total amount of free (as in: usable by programs) memory, look at the amount in the 'free'-column in the '-/+ buffers/cache' row.

Solution 4:

A similar question to this was asked in ServerFault recently

Why does Red Hat Linux report less free memory on the system than is actually available?

disclaimer: I am currently the highest rated answer on that question