Linux usually says yes when a program asks for memory, even when it does not have that much free. The program only gets a problem later, when it actually uses it. One setting controls that policy.
sysctl vm.overcommit_memory
The kernel documentation describes three values. 0, the default, is a heuristic: requests that are obviously too large for RAM plus swap are refused, the rest is allowed. 1 pretends there is always enough memory until it really runs out. 2 never overcommits: the total committed memory may not exceed swap plus a percentage of RAM, set by vm.overcommit_ratio, which defaults to 50.
Some software asks for a specific value. Redis, for example, warns at startup that background saving can fail and recommends 1, because it forks a copy of itself that would look like it needs twice the memory. Set it like any sysctl:
echo 'vm.overcommit_memory = 1' | sudo tee /etc/sysctl.d/90-overcommit.conf
I would only change it when a program asks for it. With 1, a system that really runs out depends fully on the OOM killer, which then picks a process to kill. With 2, programs get clear allocation errors instead, but the default ratio of 50 is low for a box with little swap, and things like browsers or Java can fail to start long before memory looks full. To see how much is committed now, compare Committed_AS with CommitLimit in /proc/meminfo.
Further reading: Documentation for /proc/sys/vm/, Overcommit accounting