3 ms·
Well to start, slap default resource limits on your processes so they can't use all the RAM in the world. Then your leaky processes will crash when their mallo
by saalweachter 7y ago
Well to start, slap default resource limits on your processes so they can't use all the RAM in the world. Then your leaky processes will crash when their mallocs fail and everyone will be as happy as they deserve.
- scottlamb 7y agoI agree with the idea, but a nit: on 64-bit Linux with the default vm.overcommit_memory=0, their mallocs will likely continue to succeed. Those just expand the address space, which is probably not what your resource limits are controlling. [1] The actual limit [2] is hit when they try to use the virtual address space, causing a minor page fault (when it's backed by a zero-filled page of physical RAM). [1] You can add in such a limit via RLIMIT_AS, but it'd have a lot of collateral damage like preventing LMDB from mmap()ing a big database. I don't recommend this. [2] I'd recommend setting limits on a cgroup; with a systemd unit file, see MemoryMax= and friends in the systemd.resource-control(5) manpage.
- xorcist 7y agomallocs never fails. By design. That's the whole point of all this. On Linux you can make them fail, but don't do that unless you know what you're doing.