Shrink Region by using Region.grow(region, 0)

i tried to shrink the region page to 0 but it’s still the same as before.

or this is impossible for now? if so, then i should overwrite the region starting from position 0, yes?

Can you remove all references to the Region so that it gets garbage collected?

See: Motoko Stable Regions - #12 by timo

No, you cannot shrink a region, just as you cannot shrink raw stable memory.

Unfortunately, garbage collection of regions, though planned for, is not yet implemented.

1 Like

https://internetcomputer.org/blog/2023/09/13/news-and-updates/update#moc-0100—motoko-stable-regions

What is a “region”?

A Region is a new Motoko abstract data type that uses an API which exposes low-level canister stable memory. Regions are unique since they use distinct portions of stable memory that never interfere with one another. New Regions can be created dynamically, and any old regions that are marked for garbage collection will be removed and reused for new Regions afterwards.

The bit in italics is inaccurate. I’m not sure how that got out but it is a misunderstanding.