Hacker News new | ask | show | jobs
by po1nt 14 days ago
It would be nice to have a signal as a warning to process to reduce it's memory footprint or else OOM will kill it.
3 comments

You still need some way to make the kernel to send those signals to the processes of your choosing. If the kernel decides to send SIGLOWMEM to xlock instead of firefox, the xlock will get killed because it really doesn't have any memory it can give up.
SIGLOWMEM, if it existed, would have no reason to default to anything other than IGN.

It would also logically be sent to “every” process on the machine, with the subsystem probably having a heuristic to skip processes which were already signaled and have not had significant memory increases since. The goal of an early warning is to cooperatively release memory (and maybe abort memory intensive computations), the kernel already kills processes “at random”, it does not need a second way to do that.

It’s possible via cgroups, kinda.

cgroups v1 has a pretty nice API but it requires root. V2 does not require root but it’s a lot coarser and not as simple or reliable: https://unix.stackexchange.com/questions/753929/receive-a-me...