4

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?)

6 Answers6

16

See: http://www.linuxatemyram.com

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

andrewd18
  • 874
  • 5
  • 8
4

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.

Haakon
  • 1,305
  • 7
  • 11
4

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.

wzzrd
  • 10,269
  • 2
  • 32
  • 47
2

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

Dave Cheney
  • 18,307
  • 7
  • 48
  • 56
1

Install htop to actually have that visualized.

htop

Note that memory occupied by applications or really occupied is marked green. Blue and orange are buffers and cache.

vartec
  • 6,137
  • 2
  • 32
  • 49
0

Operating systems tend not to let good RAM go to waste. Whether it is Linux or Windows or Mac OS X, you can be pretty sure all your memory that is visible to the OS has been put to good use. The OS will use everything as cache unless that memory is specifically required for something else. The way the different memory reporting utilities display a "Memory Used" single number or graph is a design decision that estimates what type of memory usage the user is most likely to want to know.

Peter Stuer
  • 1,473
  • 9
  • 11