Region API 8mb stable overhead per region?

IRCC this is actually expected behaviour.
Although you can grow a region in increments of 64k Wasm pages, the implementation actually chunks these allocations into large allocations of 128 pages. So each region will occupy at least 128 pages (8MiB), even if it was only grown by 1 page.

(The doc mentions that in this section:
Stable regions | Internet Computer)

There is also a hard-limit (–max-stable-pages) set at compile time, that limits how many physical stable memory pages your canister can use (I think that’s set to 4GB by default to allow another 4GB for stable variable storage).

Note that regions are not garbage collected and cannot be freed, so you should only use them sparingly. With the new enhanced orthogonal persistence feature now in beta,
you can probably avoid using them at all.

1 Like