If I disable memory overcommit by setting vm.overcommit_memory to 2, by default the system will allow to allocate the memory up to the dimension of swap + 50% of physical memory, as explained here.I can change the ratio by modifying vm.overcommit_ratio parameter.Let's say I set it to 80%, so 80% of physical memory may be used.My question are: what the system will do with the remaining 20%?why is this parameter required in first place?why I should not always set it to 100%?
Where the remaining memory of vm.overcommit_ratio goes?
linux;kernel;memory;out of memory
What the system will do with the remaining 20%?The kernel will use the remaining physical memory for its own purposes (internal structures, tables, buffers, caches, whatever). The memory overcommitment setting handle userland application virtual memory reservations, the kernel doesn't use virtual memory but physical one.Why is this parameter required in first place?The overcommit_ratio parameter is an implementation choice designed to prevent applications to reserve more virtual memory than what will reasonably be available for them in the future, i.e. when they actually access the memory (or at least try to). Setting overcommit_ratio to 50% has been considered a reasonable default value by the Linux kernel developers. It assumes the kernel won't ever need to use more than 50% of the physical RAM. Your mileage may vary, the reason why it is a tunable.Why I should not always set it to 100%?Setting it to 100% (or any too high value) doesn't reliably disable overcommitment because you cannot assume the kernel will use 0% (or too little) of RAM.It won't prevent applications to crash as the kernel might preempt anyway all the physical memory it demands.