[CentOS] top and allocation issues

Fri Mar 4 00:52:51 UTC 2011
Michael D. Berger <m_d_berger_1900 at yahoo.com>

On Thu, 03 Mar 2011 15:03:34 -0500, Stephen Harris wrote:

> On Thu, Mar 03, 2011 at 07:55:57PM +0000, Michael D. Berger wrote:
[...]
> 
> /proc/sys/vm/overcommit_memory
> (or sysctl vm.overcommit_memory)
> 
>>From the kernel Documentation:
> 
> This value contains a flag that enables memory overcommitment.
> 
> When this flag is 0, the kernel attempts to estimate the amount of free
> memory left when userspace requests more memory.
> 
> When this flag is 1, the kernel pretends there is always enough memory
> until it actually runs out.
> 
> When this flag is 2, the kernel uses a "never overcommit" policy that
> attempts to prevent any overcommit of memory.
> 
> This feature can be very useful because there are a lot of programs that
> malloc() huge amounts of memory "just-in-case" and don't use much of it.
> 
> The default value is 0.
>

It appears that option 2 would be the best for me, so I set:
sysctl vm.overcommit_memory=2

However, it resets to 0 on reboot, and only root can reset it.
It would be good if it would be set to 2 on reboot.  Is there
a good way to do this?  I suppose I could put something in
/etc/init.d/ if there is no better way.

Thanks,
Mike.