Re: 2.2/2.4/2.6 VMs: do malloc() ever return NULL?

Ihar 'Philips' Filipau
2003-11-25T15:23:18Z

Arjan van de Ven wrote:
>
> that is due to the overcommit policy that your admin has set.
> You can set it to disabled and then malloc will return NULL in userspace
>

Target (patched by mvista) system works as expected in case of
memory being touch.
But in case of "for(;;) malloc(N)" it still gets 1.8GB memory
allocated. (this is ppc32 - looks like 2/2 memory split) So it doesn't
look like working at all. So basicly pool allocation used in carrier
grade systems goes south: even with overcommit_memory=-1 && malloc()!=0
you can not be sure that memory is really allocated. Not good.

Vanilla 2.4.22 (this is x86) (with HZ=1024, if it does matter).

after '# echo -1 >/proc/sys/vm/overcommit_memory'
1. test app with memory touch still gets killed by oom_killer. (so
no malloc() == NULL)
2. test app w/o memory touch still can happily allocate 2.8GB of
memory (x86 - looks like 3/1 memory split) and only then gets NULL
pointer - oom_killer is silent.

But thanks for pointers in any way...

--
Ihar 'Philips' Filipau / with best regards from Saarbruecken.
-- _ _ _
Because the kernel depends on it existing. "init" |_|*|_|
literally _is_ special from a kernel standpoint, |_|_|*|
because its' the "reaper of zombies" (and, may I add, |*|*|*|
that would be a great name for a rock band).
-- Linus Torvalds