Skip to main content

default_allocator

Macro default_allocator 

Source
macro_rules! default_allocator {
    () => { ... };
    (heap = $len:expr) => { ... };
}
Expand description

Install the default bump allocator over the SVM heap region.

Opt-in counterpart to no_allocator!: use this when a program needs alloc (e.g. heap Vec/String on a cold path) while keeping the zero-copy hot path allocation-free. Never frees within an instruction; the whole heap is reclaimed when the instruction returns.

default_allocator!(heap = 128 * 1024) declares a larger heap, up to 256 KiB. The transactions that need it carry ComputeBudgetInstruction::RequestHeapFrame with the same size; the ones that allocate less than 32 KiB work without it.