News for hackers. Stuff that matters.
Re:The Linux kernel's inability to gracefully handle low mem... by azinman2 on Tuesday August 06, 2019 @01:57PM (#20627701)
I have to say, reading all these replies about the OOM killer makes Linux look quite bad. These proc scores are not an elegant solution. I far prefer Darwin’s launchd which lets you set actual memory limits (soft and hard) that gives you warnings before you cross a threshold. Now this is more consumer OS oriented, but something equivalent for servers that let you express preferences in a more natural way seems desirable.
Re:The Linux kernel's inability to gracefully handle low mem... by TheDong on Tuesday August 06, 2019 @09:05PM (#20631149)
systemd lets you configure soft and hard limits on a per-service level, almost identically to launchd. See MemoryHigh= and MemoryMax= [1].

This does depend on cgroupsv2, but it works on most modern distros.

[1]: https://www.freedesktop.org/software/systemd/man/systemd.res...

Re:The Linux kernel's inability to gracefully handle low mem... by azinman2 on Wednesday August 07, 2019 @12:52PM (#20636479)
Oh nice! Thanks for the pointer!
Re:The Linux kernel's inability to gracefully handle low mem... by jimpudar on Tuesday August 06, 2019 @02:45PM (#20628187)
You can use ulimit to set soft and hard limits for all sorts of system resources (including memory) on Linux.
Re:The Linux kernel's inability to gracefully handle low mem... by IcePic on Friday August 09, 2019 @11:34AM (#20655301)
..but if the problem is programs not checking malloc() return codes since it will not return failures, then ulimits will in themselves not help the program. It will help the OS to stay alive which is good, but we still need to deal with the programs who expect to run all the way into a swamp and sink without malloc giving them "bad news".
Re:The Linux kernel's inability to gracefully handle low mem... by azinman2 on Tuesday August 06, 2019 @04:51PM (#20629506)
True — I forgot about this. But can you do that on a process via some config _before_ the process is created?
Re:The Linux kernel's inability to gracefully handle low mem... by jimpudar on Wednesday August 07, 2019 @05:43PM (#20639463)
Yeah, usually you call ulimit before calling the process. The new process inherits the limits. If you want to modify the limits of an _existing_ process, you can use prlimit.
Re:The Linux kernel's inability to gracefully handle low mem... by the8472 on Tuesday August 06, 2019 @02:36PM (#20628099)
memory limits are also available in linux via cgroups or ulimit.