July 15, 2009

Why does Linux report 100% memory usage all the time?

I figured this would be worth posting, even though I do have a note on it on my sister site.


Why does Linux report memory usage as being 99% used even though nothing is running on the server?

I'll start with the conclusion: If little swap is being used, memory usage is not impacting performance at all.
  • Traditional Unix tools like top often report a surprisingly small amount of free memory after a system has been running for a while.
  • The biggest place memory is being used is in the disk cache which is reported by top as "cached". Cached memory is essentially free, in that it can be replaced quickly if a running (or newly starting) program needs the memory.
  • The reason Linux uses so much memory for disk cache is because the RAM is wasted if it isn't used. Keeping the cache means that if something needs the same data again, there's a good chance it will still be in the cache in memory. Fetching the information from there is around 1,000 times quicker than getting it from the hard disk. If it's not found in the cache, the hard disk needs to be read anyway, but in that case nothing has been lost in time.

1 comment: