<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 27, 2021 at 8:27 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> According my test,malloc amount greater than available memory,then invoke the oom-killer.<br>
<br>
However that does not mean that allocating MemAvailable or slightly less<br>
than MemAvailable is safe. In fact it's not, at least that I've been<br>
told be kernel developers. I will try to figure out something safe<br>
enough with their help.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">If we only hope to avoid trigger OOM during allocating until the</div><div dir="ltr"><div class="gmail_default">MAP_FAILED, I think the knob 'proc/sys/vm/overcommit_memory'</div><div class="gmail_default">maybe helpful.</div><div class="gmail_default"><br></div><div class="gmail_default">e.g.</div><div class="gmail_default"><br></div><div class="gmail_default"> set overcommit_memory = 2, overcommit_ratio<span class="gmail_default"> = 85 or 90;</span></div></div><div><span class="gmail_default"> ... memory allocating as much as you can ...</span></div><div class="gmail_default" style="font-size:small"> restore the value of overcommit_*</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>