Linux – MySQL not using specified RAM anymore

centosinnodblinuxmemoryMySQL

A few days ago I got a new machine setup running CentOS 5.6 (64bit), with 12GB ddr3 ram, 4x SAS 15k rpm drives in RAID10. On this machine I'm running MySQL Server version: 5.1.39-maria-beta-ourdelta67-log, which I have been using on previous servers as well with great results. This is my my.cnf http://pastebin.com/kLfmbHSW

Now before this morning MySQL would always use up the specified RAM that I had setup in my.cnf (about 95% of the 12GB). Instantly after staring mysql I would check 'top', and indeed 95% of the ram would be taken.

But now, after I restart MySQL i see this when i hit 'top'.

Mem: 12289856k total, 1884924k used, 10404932k free, 39660k buffers

Only about 15% is used. This number goes up a bit slowly, but before it would always use up all the RAM straight away.

What could be causing this?


Update: Since i restarted mysql, its been slowly using more and more ram, up to a point where it took up all my 12gb, and the whole machine locked up. I had to reboot linux to get it back online again. Its now on 1.8gb again, and slowly going up. The whole ram management seems to be bad, as it takes more ram, but never flushes it.

Any ideas what might be causing this?

Best Answer

It seems you are running a beta release, which tend to be buggy. However, just because you specify what memory to use, it doesn't mean that the OS will allocate it. When mysql asks the OS for the amount of memory say 8GB you have, it receives a sort of promissory note: "yeah, sure go ahead, you can have 8gb".

Then the application (mysql in this case) manages its own heap, and how much memory it uses. The usage goes up as the heap increases, as the number of queries increases. This is why you see an increase over time.

The reason why your server locked could be from many causes such as other applications using more memory than you expected, or simply there's a bug in mysql (which I tend to find unlikely).