pub fn init_allocator(max_pages: u64)
Expand description

An alias for stable_memory_init, but allows limiting the maximum number of stable memory pages that the allocator can grow. [init_allocator(0)] works exactly the same as stable_memory_init().

This function is useful for testing, when one wants to see how a canister behaves when there is only a little of stable memory available.

If this function is invoked in a canister that already grown more stable memory pages than the argument states (this can happen for canisters that migrate from standard collections to “stable” ones), then the actual number of already grown pages is used as a maximum number of pages instead of what is passed as an argument.

Passing a 0 as an argument has a special “infinite” meaning, which means “grow as many pages as needed, while it is possible”.

Internally calls StableMemoryAllocator::init.