# Minimal cycles to delete canister

**URL:** <https://forum.dfinity.org/t/minimal-cycles-to-delete-canister/15926>\
**Category:** Developers\
**Created:** [October 16, 2022, 10:59am UTC](https://forum.dfinity.org/t/minimal-cycles-to-delete-canister/15926 "2022-10-16T10:59:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [October 16, 2022, 10:59am UTC](https://forum.dfinity.org/t/minimal-cycles-to-delete-canister/15926/1 "2022-10-16T10:59:18Z")

</div>

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](https://forum.dfinity.org/t/cannot-delete-canisters-anymore/11594)) and there was a discussion about adding `freezing_threshold_in_cycles` to the spec which was discussed in the PR [#18](https://github.com/dfinity/interface-spec/pull/18).

As far as I understand it was merged but then the field was renamed to `idle_cycles_burned_per_second` in PR [#31](https://github.com/dfinity/interface-spec/pull/31).

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

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [October 22, 2022, 6:29am UTC](https://forum.dfinity.org/t/minimal-cycles-to-delete-canister/15926/2 "2022-10-22T06:29:48Z")

</div>

`idle_cycles_burned_per_day` actually seems to exists because if found it in the [ic\_cdk::api doc](https://docs.rs/ic-cdk/latest/ic_cdk/api/management_canister/main/struct.CanisterStatusResponse.html) 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? 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [October 24, 2022, 7:09am UTC](https://forum.dfinity.org/t/minimal-cycles-to-delete-canister/15926/3 "2022-10-24T07:09:19Z")

</div>

I can find some results when I search for `idle_cycles` in the [master branch version](https://github.com/dfinity/interface-spec/blob/master/spec/index.adoc) 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.
