Wednesday, January 23, 2008

Why Linux reports 100% memory usage all the time

Below is clarification as to why memory in Linux is reported as always being 99% used even though nothing may be running on the server:
  • 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.
  • Generally speaking, if little swap is being used, memory usage isn't impacting performance at all.


No comments: