Re:The Linux kernel's inability to gracefully handle low mem...
by gfv on Monday August 05, 2019 @11:17PM
(#20621811)
The fundamental problem here is that the kernel can't time-travel into the future far enough to make sure no higher-priority processes will try to allocate more memory, as the system has to make the decision to return ENOMEM at the time of the allocation. There is a reasonable(-ish?) default to deny allocations that request more memory than currently available (using the Linux definition of available, that is total memory without the sum of resident sets of all processes and a bit more). Of course, this limit only works properly if other processes do not add anything to their working sets, but again, the kernel's fortune-telling abilities are quite limited.
Re:The Linux kernel's inability to gracefully handle low mem...
by magicalhippo on Tuesday August 06, 2019 @04:25AM
(#20623292)
It can't look into the future, but it certainly could use the information from the past.
Has this application already allocated 90% of the memory? Has it been steadily growing the allocation without releasing much back? Well then, why let the system run out completely? Why not stop it at say 10% or 5% left?
Re:The Linux kernel's inability to gracefully handle low mem...
by JoshTriplett on Tuesday August 06, 2019 @01:14PM
(#20627258)
That application might be the whole point of the system and should get to use every last drop of RAM.
Re:The Linux kernel's inability to gracefully handle low mem...
by magicalhippo on Tuesday August 06, 2019 @02:20PM
(#20627920)
For a desktop OS that would be very unusual in my experience.
For a server, perhaps, but I'd say even for a server it would be better that say the core application returns a 500 internal error or whatever than forcing the system to start killing random processes.
Re:The Linux kernel's inability to gracefully handle low mem...
by johntb86 on Monday August 05, 2019 @11:34PM
(#20621902)
A lot of processes don't handle ENOMEM well. Your mail client asks for memory for a buffer to write an email and it gets ENOMEM, what's it going to do? Silently fail to do anything? Pop up an error message (which will probably take memory to display)? Exit?
Re:The Linux kernel's inability to gracefully handle low mem...
by userbinator on Monday August 05, 2019 @11:52PM
(#20621976)
Pop up an error message (which will probably take memory to display)?
I don't know how common this is on the Linux/POSIX side, but in DOS and Windows it is usual practice to allocate some amount of memory at startup and use that for error-handling code, so that things like showing error messages will not cause any more allocations.
It doesn't have to wait until it actually runs out before issuing ENOMEM. Most processes don't deserve to starve the system completely.