1

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 :)

1
  • A store clerk once told me, "We had enough gift boxes, but we ran out."
    – GZipp
    Jan 1, 2011 at 23:56

1 Answer 1

4

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 (more details). 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .