Will the 4GB heap size limit ever be increased?

Since I want to calculate how filled is my canister’s heap memory, I need to know if I should compare rts_heap_size() divide by 4000000000 or some other variable that my canister can provide. If I have to use some other variable, what variable or function i can use to get the fixed allocated/maximum heap memory for my Motoko canister?

Thank you.

You probably want to divide by rts_memory_size() which is the number of Wasm memory bytes currently used by the canister (i.e. Wasm MemorySize instruction (Wasm page count) x 65536 (Wasm page size, in bytes)), currently limited by 4GiB since we are using 32-bit wasm.

Some more explanation is here:

1 Like

Hi claudio

Thank you, claudio, for the reply. If i understand correctly, the value of rts_memory_size keeps on increasing based on how much a canister use. I did test this on Motoko Playground and keep inserting 1 million Nats, and everytime the heap_size about to reach the memory_size, the memory_size increased, which is behaving as what you guys described.

So does this mean if i want to get how filled my canister is, i should rts_heap_size divide with 4294967296. If so, then this heap size limit is fixed forever yes? Also thanks for correcting me that it’s 4 GiB, not 4GB.

oh nevermind!
i found this

So i can actually used the fixed number to check if my canister is almost filled like so:

public func isFilled() : Bool {
  return rts_heap_size() / 4294967296 * 100 > 99;
}

thanks for your time, claudio