Minimal cycles to delete canister

Is there now an information that can be use to determine the minimal amount of cycles that needs to be retain before deleting a canister?

Earlier this year there wasn’t such information (post) and there was a discussion about adding freezing_threshold_in_cycles to the spec which was discussed in the PR #18.

As far as I understand it was merged but then the field was renamed to idle_cycles_burned_per_second in PR #31.

Then I loose track and it seems that none of these now exists in the spec.

idle_cycles_burned_per_day actually seems to exists because if found it in the ic_cdk::api doc but don’t think “amount of cycles burned per day.” is actually that information I am looking for.

Did the original discussion totally shift and ultimately no information regarding the minimal cycles to preserve to delete a canister was added? :man_shrugging:

I can find some results when I search for idle_cycles in the master branch version of the spec.

Anyways, what are you trying to do? I would assume it’s about removing as many cycles as possible from a canister before deleting it. To find the optimal number of cycles, we’ll have to look at how freezing works:

  • A canister gets frozen (rendered unresponsive) if it goes below freezing_threshold * cycles_burned_per_second (the freezing threshold is a number of seconds)
  • cycles_burned_per_second is determined by the amount of memory the canister uses. (Remember the 5$/GB/year? that’s what that refers to)
  • The freezing threshold can be updated to arbitrary numbers: dfx canister update-settings --freezing-threshold <seconds>
  • Assuming you set the freezing threshold to something tiny (say 10 seconds for example) you should be able to send out almost all cycles in the canister before stopping/deleting it
  • For exact numbers I recommend you test locally. The local replica’s behaviour in regards to cycles should exactly mirror mainnet.