I have a virtual server just for MySQL for a handful of apps. It's a 256 MB server. There is currently barely any data in there, but free -m
shows full memory usage:
total used free shared buffers cached
Mem: 245 197 47 0 23 120
-/+ buffers/cache: 53 192
Swap: 511 2 509
This is on Ubuntu 10.04. All the configuration settings are default IIRC -- key buffer is 16, query cache is 16. (I might be missing some
So, it seems to me that with barely any data and no special settings for the buffers, I should be using well below 256. Is 256 just the lower table for what an OS + MySQL need these days?
As Jeff mentioned, the usage numbers on Linux can be confusing. Linux will automatically keep a copy of files you access in RAM. If you need them again, they're quicker to access than going back to disk. If more RAM is needed by running programs, these cached items can be tossed entirely. This makes sense. Unfortunately, the
free
command shows you numbers in a way that includes those cached files, and makes it appear you're almost out of RAM.You really want to look more at the second line, than the first. That one is the memory usage without the buffers/cache data included. In your case, it shows that you are using 53MB, and have 192MB free.
--Christopher Karel
RAM is used to hold frequently-used bits in faster storage than the hard drive. The far-right column in free tells you that half of your RAM is being used to cache from the hard drive.
If you're not using all your RAM, you're wasting resources. Dropping cache in a memory-starved situation is practically free, whereas reading from disk if something isn't cached is orders of magnitude slower.