Function allocator_api::alloc::set_oom_hook[][src]

pub fn set_oom_hook(hook: fn(_: Layout))

Registers a custom OOM hook, replacing any that was previously registered.

The OOM hook is invoked when an infallible memory allocation fails, before the runtime aborts. The default hook prints a message to standard error, but this behavior can be customized with the set_oom_hook and take_oom_hook functions.

The hook is provided with a Layout struct which contains information about the allocation that failed.

The OOM hook is a global resource.