Rust stable memory manage;

dfx 0.9.3

dfx.json

“defaults”: {
“build”: {
“args”: “–max-stable-pages=131072”,
“packtool”: “”
}

storage data use stable::stable64_write/stable64_read.

dfx canister status storage

Canister status call result for storage.
Status: Running
Controllers: gokcp-iiiub-i2xep-baqw3-vqkam-eon3v-7qrdu-h3pyt-vsha6-y7vbr-4ae rwlgt-iiaaa-aaaaa-aaaaa-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(2142876162)
Balance: 4_000_000_000_000 Cycles
Module hash: 0x5b5ef617b8c0adf4a8d723ec0febbd178deda9215d8baa0d816ef21d78e41aaa

dfx canister install storage --mode upgrade

Error: The Replica returned an error: code 5, message: “Canister rrkah-fqaaa-aaaaa-aaaaq-cai trapped explicitly: Panicked at ‘capacity overflow’, library/alloc/src/raw_vec.rs:518:5”

How to allocate 8g of stable memory ?

During this time, I implemented a simple stable memory using rust, which can store 8GB data, and the canister can be upgraded normally

2 Likes