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 vps with CentOS 5 (32bit) and it has 256mb of ram, although not much it is enough for me. On idle with 2 ssh connections active and httpd running it uses about 40mb of ram, but as soon as I start MySQL it shoots up to 220mb! Is there any way of optimizing the ram usage? I am only doing some light dev work on it.

Cheers :)

share|improve this question
    
A store clerk once told me, "We had enough gift boxes, but we ran out." –  GZipp Jan 1 '11 at 23:56

1 Answer 1

First of all, how are you showing the amount of RAM free? If it's via the "free" command, note that you need to be looking at the second row under "free", not the first. For example:

             total       used       free     shared    buffers     cached
Mem:       8191172    8059600     131572          0     169792    6648500
-/+ buffers/cache:    1241308    6949864
Swap:            0          0          0

In my case I have 8GB of RAM, but nearly 7GB of that is in buffers+cache, so my true free memory is 6.9GB, instead of the 131MB in the first column under "free".

But, as you say, 256MB of RAM isn't much. You say "it's enough for me", but if you are running out of memory with the apps running that you want, maybe you need to reconsider how much you really need.

That said, I think you probably can get your memory use more under control. First make sure you are looking at the right numbers (as mentioned above). I have a MySQL daemon running on one of my machines that gets regular but not heavy use, and it seems to be using 30MB of resident memory as shown by ps awwlx | grep mysql. It's using another 160MB of virtual though, so it may be pretty tight.

You can try adjusting the settings in the my.conf file to reduce the number of caches and other things, if you really want to try to shave the size of the use. Here is a good discussion of mysql memory parameters.

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.