Table of Contents

You have 4GB physical memory, but you allocate an 8GB buffer. Is this possible? If so, how? How is the memory actually read as we traverse the memory?

Linux has 3 modes for handling memory allocations (overcommit):

Since processes require 8MB of RAM to run, and you’d have many processes + other processes that might map virtual memory to their address space, often a lot of RAM is unused at any given time. Due to this, if overcommit was disabled, far fewer applications would be able to run concurrently. Of course, overcommit does eventually cause paging errors, but at that point the computer is clearly overloaded.

You could setrlimit to set resources or use cgroups, if you’d like to guard against overcommitting.