The behavior is normal. Quoting man 3 malloc :
ERRORS
By default, Linux follows an optimistic memory allocation strategy. This means that when malloc () returns non-NULL, there is no guarantee that memory is actually available. This is a very bad mistake. In case it turns out that the system is not in memory, one or more processes will be killed by the infamous OOM killer. In the case of using Linux in conditions where it would be less desirable to suddenly lose some by accident and, in addition, the kernel version is quite modern, you can disable this excessive behavior by using the following command:
# echo 2 > /proc/sys/vm/overcommit_memory
See also the kernel documentation directory, vm / overcommit-accounting and sysctl / vm.txt files.
You need to touch (read / write) the memory for the Linux kernel in order to actually reserve it.
source share