# Flux: How to minimise the garbage collection time?

**URL:** <https://discourse.julialang.org/t/flux-how-to-minimise-the-garbage-collection-time/97572>\
**Category:** Machine Learning\
**Tags:** question, flux\
**Created:** [April 17, 2023, 1:27pm UTC](https://discourse.julialang.org/t/flux-how-to-minimise-the-garbage-collection-time/97572 "2023-04-17T13:27:32Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![onurcanbektas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/onurcanbektas/32/46622_2.png) [@onurcanbektas](https://discourse.julialang.org/u/onurcanbektas)\
**Post date:** [April 19, 2023, 11:38am UTC](https://discourse.julialang.org/t/flux-how-to-minimise-the-garbage-collection-time/97572/21 "2023-04-19T11:38:17Z")

</div>

because

1. GC running at every step
2. one loop takes much longer time than my code.  
%10 of 10s is still 1s of GC time - which is still A LOT.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 19, 2023, 1:20pm UTC](https://discourse.julialang.org/t/flux-how-to-minimise-the-garbage-collection-time/97572/22 "2023-04-19T13:20:28Z")

</div>

right, but the thing that was really surprising about your original example was that GC was running every 4 times even though you were barely allocating. In this example, you are allocating 34gb per run and GC is running multiple times per loop.

---

<div class="post-metadata">

**Author:** ![onurcanbektas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/onurcanbektas/32/46622_2.png) [@onurcanbektas](https://discourse.julialang.org/u/onurcanbektas)\
**Post date:** [April 20, 2023, 7:26am UTC](https://discourse.julialang.org/t/flux-how-to-minimise-the-garbage-collection-time/97572/23 "2023-04-20T07:26:11Z")

</div>

Ah, I see. Let me see how to reproduce the same issue with the examples I gave. But thanks for the help so far - really appreciated.

[Previous page](https://discourse.julialang.org/t/flux-how-to-minimise-the-garbage-collection-time/97572.md?page=1)
