Heap size vs canister_status.memory_size

Yesterday, I received some answers regarding how to query the memory (thread). I am now comparing two approaches, and I am getting different values.

When I deploy a canister and install its wasm, I obtain different values when comparing canister_status and memory_size:

Through canister_status, I get a memory_size of 30.02 MB, while core::arch::wasm32::memory_size(0) returns 28 (approximately 1.75 MB) if I’m not mistaken.

I assume these two numbers indicate different things, but what am I missing?

Somehow give a brand new canster with only few heap data, I naively assumed that both would indicate the same size.

1 Like

The size difference oddly looks similar to the same difference in my today’s thread about stable structure. Therefore, I would guess this is for the same reason, and I can close this thread in favor of the other: https://forum.dfinity.org/t/stable-memory-consumed-even-if-not-used/25599/2?u=peterparker