Motoko, Array, Memory

Thanks Matthew. So to highlight something from his reply, my statement from my own answer earlier,

was not actually correct. The IC will still charge you a storage fee for the entire memory_size. I’m sorry for spreading wrong information before!

We have been discussing to extend the IC with some way for an application to signal that a certain part of the memory is “unused” (nulled out) and can hence be eliminated from storage (effectively, providing a sort of shrink through the backdoor). But that does not exist yet.

For Motoko that means that you should be even more careful not to create excessive garbage in a message, since that might temporarily blow up the heap size but Motoko has no way to “return” it.

2 Likes