Linux VM: Overcommit Memory and Ratio

Smoot Carl-Mitchell smoot at tic.com
Wed Mar 18 18:09:05 UTC 2009


On Wed, 2009-03-18 at 17:42 +0000, Anthony M. Rasat wrote:
> Heya guys,
> 
> I had a OOM (Out Of Memory) situation. This machine have 512 MB RAM
> and 1 GB swap running Apache MySQL PHP. Something went wrong in PHP
> (which I'm not gonna discuss) and MySQL ended up wanted memory more
> than system ever owned.
> 
> Now, to avoid that incident in future, I
> readjusted /proc/sys/vm/overcommit_memory to 2 (default 0)
> and /proc/sys/vm/overcommit_ratio to 50 (default 50 too).
> 
> My question is what side effect will showed up? Will MySQL start to
> slowing down? Will Apache begin to fail? I know more RAM is better
> idea but what if PHP gone berserk again? Will it better if OOM killer
> kept loose otherwise? Thanks for your insights.
> 

With the settings you have, you could still overcommit virtual memory.
So the OOM state could still occur depending on the VM sizes of your
process mix.  You have reduced the likelyhood of this event, since the
default is to allow malloc() to always succeed and you have the VM
system set to fail malloc()s when the total virtual memory size of all
processes exceeds swap plus half of your physical memory. You could set
the overcommit_ratio to 0 and be guaranteed there is enough paging space
for all processes.

With the above in mind, I think your performance should be about the
same.  You are simply allowing processes to die when they run out of
memory.  This is assuming the programs handle failed malloc() calls
gracefully.
-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list