3 ms·
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 l
by azinman2 7y ago
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.
- the8472 7y agomemory limits are also available in linux via cgroups or ulimit.
- jimpudar 7y agoYou can use ulimit to set soft and hard limits for all sorts of system resources (including memory) on Linux.
- azinman2 7y agoTrue — I forgot about this. But can you do that on a process via some config _before_ the process is created?
- jimpudar 7y agoYeah, 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.
- IcePic 7y ago..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".
- TheDong 7y agosystemd 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.resource-control.html#MemoryLow=bytes https://www.freedesktop.org/software/systemd/man/systemd.res...
- azinman2 7y agoOh nice! Thanks for the pointer!