Let's say if we wish to ensure that the kernel only gives out memory to processes equal to the physical memory, then we have to do the following at /etc/sysctl.conf or /etc/sysctl.d/myapp.conf
My assumption is that you have 10GB of swap and 20GB of memory and you wish the kernel to stop handling processes at 18GB RAM, then the calculation should be (swap size + 0.4 * RAM size)
So at /etc/sysctlf.conf, the configuration will be
vm.overcommit_memory = 2 vm.overcommit_ratio = 40Note: The ratio is (40/100). For explanation of vm.overcommit_memory =2. Do look at Tweaking Linux Kernel Overcommit Behaviour for memory
Once the memory hits 18GB, the so-called OOM killer of the Linux kernel will kick in.
Another calculation example is that your RAM size and SWAP size are the same and you wish exactly the physical memory to be used only. then
vm.overcommit_memory = 2 vm.overcommit_ratio = 0
For more information, do read
No comments:
Post a Comment