Re:If malloc fails, it's not for the obvious reason
by scvalex1 on Friday November 02, 2012 @10:15PM
(#4735683)
Everything's ok until you try to write to more memory than is available. At that point, either your program segfaults, or Linux's Out-Of-Memory (OOM) Killer is invoked and kills a random process (not necessarily the offending process).
[ Parent
| on HN ]
Re:If malloc fails, it's not for the obvious reason
by rosser on Saturday November 03, 2012 @12:31AM
(#4735895)
(not necessarily the offending process)
It's terrible about this with PostgreSQL. The OOM Killer tends to thump the postmaster, not the offending backend.
Re:If malloc fails, it's not for the obvious reason
by EdiX on Saturday November 03, 2012 @03:43AM
(#4736139)
You should instruct the OOM Killer to not kill PostgreSQL.
Memory is a global resource, even if you didn't overcommit the process getting the allocation failure is not guaranteed to be the misbehaving one, it's just the unlucky process that did the first allocation after all the memory was gone (this is also why handling allocation errors in your application is usually impossible, even without an overcommitting kernel).
Re:If malloc fails, it's not for the obvious reason
by pyre on Saturday November 03, 2012 @01:33PM
(#4737255)
It's not something that's easy to develop a general solution to. Maybe the process that's using a lot of RAM is not runaway, and is mission-critical. Maybe it is a runaway process and something else is mission-critical.
The most 'fair' way to go about it is to just kill a random process. That skits the whole issue.