Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
    
192MB free! right under my nose. Thanks! –  John Bachir Dec 2 '10 at 17:13
    
+1 for the world's cheapest memory upgrade :) –  SmallClanger Dec 2 '10 at 18:14

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.