# How does canister stable memory really work?

**URL:** <https://forum.dfinity.org/t/how-does-canister-stable-memory-really-work/20127>\
**Category:** Developers\
**Created:** [May 21, 2023, 3:34pm UTC](https://forum.dfinity.org/t/how-does-canister-stable-memory-really-work/20127 "2023-05-21T15:34:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamenochchirima](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/iamenochchirima/32/21673_2.png) [@iamenochchirima](https://forum.dfinity.org/u/iamenochchirima)\
**Post date:** [May 21, 2023, 3:34pm UTC](https://forum.dfinity.org/t/how-does-canister-stable-memory-really-work/20127/1 "2023-05-21T15:34:23Z")

</div>

Does the canister stable memory only work during canister upgrade to store the actor variables data and then restore the data after upgrades to the heap memory?  
Is there a way I can store certain data in the stable memory and then use it in the heap only when I need it?  
Thank you.

---

<div class="post-metadata">

**Author:** ![pramitgaha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/pramitgaha/32/11659_2.png) [@pramitgaha](https://forum.dfinity.org/u/pramitgaha)\
**Post date:** [May 21, 2023, 4:25pm UTC](https://forum.dfinity.org/t/how-does-canister-stable-memory-really-work/20127/2 "2023-05-21T16:25:53Z")

</div>

if you’re using rust, then you can do that using [ic-stable-memory](https://github.com/seniorjoinu/ic-stable-memory)
