Storage of Canister 400GBs but actually it is 4Gb

based on above article we are not actually storing our entire data on stable memory,
The data actually is present in heap memory. It goes in stable memory only when we upgrade our canister or stop. It after the upgradation of canister is complete ,the data from stable memory is cleared and reverted back to heap.
This mean we can only store 4Gibs of data in single canister.
Then what is purpose of giving 400GiBs of stable memory when we can only use 4Gbs
@Gabriel

1 Like

In order to leverage stable memory not only to preserve heap memory across upgrades, you need to use data structures that are directly stored in stable memory.

In Rust, you can use GitHub - dfinity/stable-structures: A collection of data structures for fearless canister upgrades..
Azle currently exposes a StableBTreeMap.
Motoko provides a Stable Regions API. @tomijaga is working on data structures that leverage this API.

There’s also work on Enhanced Orthogonal Persistence which will allow Motoko to have heap memory of the size of stable memory and that is persistent over upgrades.

7 Likes