Stable Storage

Every canister on the Internet Computer (IC) currently (May 2023) has 4GB of working memory. This memory is wiped out each time the canister is upgraded.

On top of that, each canister currently (May 2023) gets an additional 48GB of storage space, which is called stable storage. This storage is persistent and is not wiped out during reinstallation or upgrade of a canister.

We can directly use this memory by interacting with experimental the low-level API from base library, but this is not ideal in many cases.

Work is underway for so called stable data structures that are initiated and permanently stored in stable memory. See for example this library for a Stable Hashmap.

Stable memory and upgrades

To preserve the working memory during upgrades, we may use system functions like pre_upgrade and post_upgrade to temporarily store the data in stable storage during the upgrade and copied back over to the working memory after the upgrade.