I get it now. So basically a canister memory upon creation is tiny and it will increase in time if there’s enough available in the subnet. If I manually allocate the max ie: 4GB or any number bigger than the initial allocated memory it will automatically reserve the memory and thus I need to pay for it when requested.
Yeah that error is misleading in the sense I had 1T cycles in my canister but in order to reserve the memory I needed 2.1T.
I believe what you see here is that you need 1T (which is what you want to seed your canister initially with) + 1T (which is the canister creation cost on application subnets) + some change. The creation cost is flat and the amount you specify when you make the call to create the canister is essentially the extra that your canister will be left with.
Is there a way to calculate how much you need to pay extra upon reservation and after?
The cost per GB per second is listed here (if you’re on a verified subnet, please use the corresponding value in the same file). The comment above mentions what you need per GB per year, so you can extrapolate.
How high is the probability that a canister won’t find enough memory in a subnet?
It’s difficult for me to provide a clear-cut answer. It depends on a couple of factors, including how many canisters are running, how many have attempted to reserve memory or use a lot of memory etc. I expect that subnets still have enough capacity since the usage is just now starting to ramp up, so if I had to guess, I’d say low now but probably higher in the future.
This is basically a trade-off that I think is up to the developer to choose. From my side, the advice I’d give you is to make a back of the envelope calculation and if your budget affords it, then set the max you want to be safe. Otherwise, you’ll have to program your canister defensively and handle situations where it might not be able to reach the max you’d want.
Also is there a time difference when say I add more data(eg: a 40mb file split in blob chunks) to a canister and needs to increase than a canister with memory already increased?
Not sure I understand exactly what you mean here. Note that reserving memory by setting the memory allocation does not mean that your canister has already increased its size to all this memory. It means that the system keeps it aside for you, for when you need it. But you’re sure you can grow up to and including your memory allocation at any time. So, it’ll be the same if you want to add a 40mb file to a canister with a memory allocation and a canister without (if they need to increase their current memory footprint to support this request) with the additional potential failure to increase for the canister that hasn’t reserved that memory upfront.
Let me know if this captures the intent of your question or otherwise please follow up with a clarification and I’ll get back to you.