3 ms·
You can set ulimits for memory (IIRC max vss, but check bash manpage). Then sbrk and mmap will honor the limits, which will cause malloc to fail gracefully.
by ycombobreaker 9y ago
You can set ulimits for memory (IIRC max vss, but check bash manpage). Then sbrk and mmap will honor the limits, which will cause malloc to fail gracefully.
- geofft 9y agoNote that this is a limit on virtual memory - the OOM killer triggers on running out of physical memory (or swap). It certainly helps more than not using it, but it's hard to tune exactly, because it ignores the specific thing that the OOM killer is designed to support: applications allocating large amounts of virtual memory and not using it so that no backing physical memory/swap needs to be allocated.