Increased Canister Smart Contract Memory

Increasing Stable Memory to 32 GiB

As part of this effort to give canisters more memory we’re proposing to increase the size of stable memory to 32 GiB in an upcoming release. In addition to benefiting all canister developers, this expansion is a critical part of the Bitcoin integration work.

How to use it

You won’t need to make any changes in how you call the 64-bit stable memory APIs. Calls to stable64_grow will now let you increase stable memory up to 32 GiB. Note that the stable64_size and stable64_grow functions work with Wasm pages which are 64 KiB, so this corresponds to 524,288 Wasm pages.

Limitations

Due to technical limitations of the current implementation, writes to stable memory will be limited to 8 GiB per message. This means that existing canisters will not see any breakage and all canisters will still be able to copy the entire Wasm heap to stable memory in pre-upgrade hooks. But canisters which want to take advantage of the full 32GiB should consider a design where most persistent data is used directly from stable memory. Libraries like ic_stable_structures and ic-stable-memory can help with this.

22 Likes