3 ms·
I'm a bit out of my depth here, but maybe you could solve this by: echo 1 > /proc/sys/vm/overcommit_memory According to documentation, 0 (the default) mea
by umanwizard 7y ago
I'm a bit out of my depth here, but maybe you could solve this by:
echo 1 > /proc/sys/vm/overcommit_memory
According to documentation, 0 (the default) means usually allow overcommits according to some heuristic (which was probably failing in your case), 1 means always allow, and 2 means don't allow.
Edit: It appears from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/util.c#n682 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin... that things will go wrong if you try to allocate more VM space in one call than the total free RAM+swap available to the system.
- terlisimo 7y agoYes, one example where overcommit can be better than swap is Redis. When redis is persisting its state to disk, it temporarily needs 2x the memory because it forks a child that does this in the background. Since fork uses copy-on-write, only the difference between child/parent is actually consumed as extra memory. The rest is "de-duplicated" in a sense. The choice is then to 1) enable swap, possibly killing performance 2) enable overcommit, possibly killing the redis process It is sometimes preferable for a service to fail hard and fast than get bogged down with swap. I believe this is the idea behind the "no swap" policy, at least on Linux. Redis is a good example here because any amount of swapping will kill performance since literally all of its allocated memory is consistently accessed for the purposes of doing a dump. And Linux will always try to swap things out, even with vm.swappiness=1.