Christopher Friedt wrote:
> Likely, yes.
>
> The funny thing about linux (if you check man malloc) is that there is
> no gaurantee that malloc'd memory is actually there. To quote the author
> of the man page "this is a really bad bug".
Saying that this is a really bad bug just shows that the guy that wrote
the man page doesn't have a clue about the way the Linux VM subsystem
works and the magic that it does to keep everything working.
Just check this old thread (bare in mind that this is from March, 1995):
http://groups.google.com/group/comp.os.linux.development.apps/browse_frm/thread/eaca185ceada7efc/77537d4a28245300?tvc=1&q=#77537d4a28245300
and in particular this post from Linus:
http://groups.google.com/group/comp.os.linux.development.apps/tree/browse_frm/thread/eaca185ceada7efc/f65e73097867c865?rnum=61&_done=%2Fgroup%2Fcomp.os.linux.development.apps%2Fbrowse_frm%2Fthread%2Feaca185ceada7efc%2F77537d4a28245300%3Ftvc%3D1%26q%3D%26#doc_580f0d3ce32afb27
> You can switch off the 'overcommit' bug by doing
>
> # echo 2 > /proc/sys/vm/overcommit_memory
>
> I would imagine that makes malloc return a gauranteed section of memory.
>
> Does this relate somehow as well to linux killing random processes when
> it runs low on memory?
It sure does ;)
It is a bit rude to call it random, though. The OOM killer still tries
to select "good" processes to kill :)
Anyway, when this happens you don't actually have enough memory for your
"resident set", not to mention that most of the executable code is
already pushed out (because it can be recovered from persistent
storage). If you set the overcommit setting to "2", malloc will start
returning NULL much, much sooner than that.
When you get to this point, it is a clear sign that your hardware can't
handle the requirements of your problem. There is nothing the kernel can
do about it.
As a disclaimer, there have been a few bugs in the OOM killer in the
past that made it trigger with swap space still available and other
similar scenarios. These were *bugs* and they have nothing to do with
the way the VM *should* work.
I'm sorry about the long post, but this overcommit question comes up
much too often, and people are not aware of its complexity most of the time.
See ya,
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|