# How to get the size of my data?

**URL:** <https://forum.dfinity.org/t/how-to-get-the-size-of-my-data/40948>\
**Category:** Developers\
**Created:** [February 7, 2025, 9:11am UTC](https://forum.dfinity.org/t/how-to-get-the-size-of-my-data/40948 "2025-02-07T09:11:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [February 7, 2025, 9:11am UTC](https://forum.dfinity.org/t/how-to-get-the-size-of-my-data/40948/1 "2025-02-07T09:11:17Z")

</div>

```rs
use ic_stable_structures::memory_manager::{MemoryId, MemoryManager, VirtualMemory};

use ic_stable_structures::{
    storable::Bound, DefaultMemoryImpl, StableBTreeMap, StableVec, Storable,
};

type Memory = VirtualMemory<DefaultMemoryImpl>;
static PROFILE_STORE: RefCell<StableBTreeMap<String, User, Memory>> = RefCell::new(
        StableBTreeMap::init(
            MEMORY_MANAGER.with(|m| m.borrow().get(MemoryId::new(0))),
        )
    );

```

How to get the size of `PROFILE_STORE`?

---

<div class="post-metadata">

**Author:** ![frankdavid](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/frankdavid/32/20846_2.png) [@frankdavid](https://forum.dfinity.org/u/frankdavid)\
**Post date:** [February 7, 2025, 2:03pm UTC](https://forum.dfinity.org/t/how-to-get-the-size-of-my-data/40948/2 "2025-02-07T14:03:17Z")

</div>

Hi AliSci,

What exactly do you mean by the size?

- VirtualMemory works with buckets, the default size of a bucket is 128 wasm pages, i.e. 8MB, meaning that by default, that’s the minimum size a data structure will take up in stable memory (or a multiple of that if the data structure gets bigger). You can use `MEMORY_MANAGER .get(..).size()` to get the allocated memory for a bucket (in wasm pages).
- Even within StableBTreeMap, the implementation works with pages (the size of which depends on the data type stored in the map, see it [here](https://github.com/dfinity/stable-structures/blob/8c75149f29d428b2d1030dc5fa7e4fcc3488e35a/src/btreemap.rs#L182)), so the space the StableBTreeMap actually takes up in the VirtualMemory is a multiple of this (+ some metadata per page).
- Because there is no clear definition of size, the library doesn’t expose this data in a public API, however, you could fork it and access the `allocator` field inside StableBTreeMap and read `allocator.num_allocated_chunks() * allocator.chunk_size()`.

If you tell us about your use-case, perhaps we can give you more advice.
