# Understanding how GC is triggered

**URL:** <https://discourse.julialang.org/t/understanding-how-gc-is-triggered/55015>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [February 10, 2021, 6:25pm UTC](https://discourse.julialang.org/t/understanding-how-gc-is-triggered/55015 "2021-02-10T18:25:23Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [February 10, 2021, 11:00pm UTC](https://discourse.julialang.org/t/understanding-how-gc-is-triggered/55015/4 "2021-02-10T23:00:57Z")

</div>

I agree that GC cannot be disabled as, in particular sometimes GC must be triggered as otherwise you would run out of memory.

I suspect (I will do more tests tomorrow) that for some reason, as @jeff.bezanson commented in [When does the garbage collector runs?](https://discourse.julialang.org/t/when-does-the-garbage-collector-runs/15142), there is no 100% sure way to force GC inside a function at a given point (and it gets triggered later when Julia runs out of RAM inside `@btime`).

However, this would mean that benchmarking should be performed at top-level scope only. Is this a correct conclusion?

---

_[View the full topic](https://discourse.julialang.org/t/understanding-how-gc-is-triggered/55015)._
