Allowing small allocations to fail
Allowing small allocations to fail
Posted Mar 11, 2015 18:26 UTC (Wed) by dlang (guest, #313)In reply to: Allowing small allocations to fail by roblucid
Parent article: Allowing small allocations to fail
memory overcommit is not your fundamental problem here. In fact, it help avoid the problem the vast majority of the time.
The problem is not userspace applications handling memory failures (I don't understand how the discussion here has focused on userspace), the problem is the kernel allocating memory.
The fundamental problem is that memory is finite, when it's full and you want to write something to disk to free the memory, the process of writing the data out can involve memory allocations (in the filesystem, raid layer, lvm layer, network layer if using iscsi, etc). How do you handle this case?
As discussions have shown, you cannot know ahead of time how much memory these can require, so simply having some reserved memory isn't the answer (at least, it's not that simple to figure out how much memory to reserve)
The deeper the stack of layers that you have to go through to write a chunk of memory out to disk, the more likely you are going to run into problems.
If you use a swap partition on a SATA drive directly, there is far less chance of running into problems that if you are using a swap file on ext4 on top of LVM (with snapshots) on a RAID array connected over iSCSI (which is not an unreasonable setup)