Skip to main content

try_box_uninit

Function try_box_uninit 

Source
pub fn try_box_uninit<T>() -> Option<Box<MaybeUninit<T>>>
Expand description

An UNINITIALISED heap allocation for one T, or None if the global allocator is exhausted.

The fallible form of Box::<T>::new_uninit(), for a value too large to build on the stack and move in (issue 0756 – the parameter store is 285,696 bytes at the default sizing, and try_box takes its value BY VALUE, which materialises all of it in the caller’s frame first). The caller initialises through the pointer and then assume_inits, exactly as with new_uninit.

Issue 1706 – that store is the one allocation every parameter declaration reaches, on every RTOS, and new_uninit sent its failure to the OOM handler: a halt (Zephyr’s HEAP EXHAUSTED then issue 0589’s recursion) or a MALLOC FAILED hang (FreeRTOS heap_4), never a refusal the declaration could return.