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?)
See: http://www.linuxatemyram.com
See also: http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
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.
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:
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.
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
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.