|
|
|
|
|
by concrete-faucet
3009 days ago
|
|
Well, what about adding a new signal (SIGXMEM) with a default action of ignore? If the system is running low on memory it can send this to some or all processes and wait for a little bit to see if things get better. This is how iOS has handled things since version 2.0:
https://developer.apple.com/documentation/uikit/uiapplicatio...
> It is strongly recommended that you implement this method. If your app does not release enough memory during low-memory conditions, the system may terminate it outright. |
|
(Signals for asynchronous conditions are an awkward interface because they can interrupt you between any two assembly instructions. You're not able to release memory in the handler itself; you have to set a flag that gets handled by the main loop. So eventfd makes sense here. I'm assuming iOS is doing something similar by queueing an Objective-C method call. Signals make a lot more sense for segfaults and the like, where you're being interrupted at the exact instruction that isn't working and you need to handle it before executing any more instructions.)