# Canister Memory Management & Data Memory Requirements

**URL:** <https://forum.dfinity.org/t/canister-memory-management-data-memory-requirements/44849>\
**Category:** Developers\
**Created:** [April 25, 2025, 11:35am UTC](https://forum.dfinity.org/t/canister-memory-management-data-memory-requirements/44849 "2025-04-25T11:35:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![antinutrino](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@antinutrino](https://forum.dfinity.org/u/antinutrino)\
**Post date:** [April 25, 2025, 11:35am UTC](https://forum.dfinity.org/t/canister-memory-management-data-memory-requirements/44849/1 "2025-04-25T11:35:07Z")

</div>

Hi

Curious to know if any api exists yet that accurately report on the current memory consumed by a canister from motoko or any other language?

Also do we have anything like sizeof to accurately provide the memory footprint for a piece of data?

Interested in trying to build out a sharding library that supports auto scaling canisters.

Thanks

---

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [April 25, 2025, 5:06pm UTC](https://forum.dfinity.org/t/canister-memory-management-data-memory-requirements/44849/2 "2025-04-25T17:06:08Z")

</div>

You can use `Prim.rts_heap_size()` in Motoko to synchronously get a canister’s current heap memory.

Here’s an example of how I used it to build auto-scaling into CanDB - [CanDB/src/CanDB.mo at d76760914f424bec8755bf15ece0fc491c1574ec · ORIGYN-SA/CanDB · GitHub](https://github.com/ORIGYN-SA/CanDB/blob/d76760914f424bec8755bf15ece0fc491c1574ec/src/CanDB.mo#L134)

Feel free to take sharding ideas from that repo and concept as well.
