News for hackers. Stuff that matters.
Re:Linux Memory Overcommit (2007) by fulafel on Monday August 19, 2024 @03:20AM (#41288602)
With overcommit disabled, fork may fail, but your other claims are backwards: malloc can fail, and processes aren't killed.
Re:Linux Memory Overcommit (2007) by cyberax on Monday August 19, 2024 @12:23PM (#41292374)
I suggest trying that :) You'd be surprised.

glibc allocator, like pretty much any other allocator, maps pages in advance without touching them. It's quite likely that you'll get OOM killed when you first try to touch them, rather than during mmap() for new pages.

Re:Linux Memory Overcommit (2007) by fulafel on Monday August 19, 2024 @10:39PM (#41296271)
Assuming you've also set overcommit_ratio to a conservative value, this would mean that the kernel overcommit=2 setting is not working, since mmap-ing writable pages counts as allocation from overcommit POV. It's a kernel sysctl, so I wouldn't expect it to change glibc's behaviour. There don't seem to be any open bugs about this in the kernel bugzilla. But do tell if you have found a bug in this area.

(This is documented in https://www.kernel.org/doc/html/latest/mm/overcommit-account... )