Description
In using this function I am wondering a few things:
-
What happens if I oom while handling an oom? Is the oom handler called again? Does the process immediately abort (ala panic)?
-
Does triggering oom remove the custom oom handler? The presence of
take_alloc_error_hook
makes it seem like that may the case, but it is not. It looks like the custom handler stays in place through its invocation. Docs would be better to mention that it's possible to oom recursively and invoke your oom handler recursively. -
Is OOM the only time that memory allocation fails? The document doesn't mention "out of memory", but the situation this handles is commonly called "OOM". The docs would better mention "out of memory" and whether there is a distinction between allocation failure types.
-
Does
take_alloc_error_hook
restore the default error hook?
Are the answers to these questions known and intended? Please add them to the docs.
Here are some harder questions:
Can I and should I try to recover from an oom? The oom handling mechanism calls abort after calling the oom handler, but what if I panic in the handler?
I could empty my caches or otherwise mess with the allocator, panic, catch the panic, and try to continue. Is that a valid and intended use case?