# GC occurs at the worst time in tight loop (Garbage Collection)

**URL:** <https://discourse.julialang.org/t/gc-occurs-at-the-worst-time-in-tight-loop-garbage-collection/104934>\
**Category:** Performance\
**Tags:** question\
**Created:** [October 13, 2023, 4:45pm UTC](https://discourse.julialang.org/t/gc-occurs-at-the-worst-time-in-tight-loop-garbage-collection/104934 "2023-10-13T16:45:17Z")\
**Posts on this page:** 1\
**Showing post:** 39

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [October 17, 2023, 2:20am UTC](https://discourse.julialang.org/t/gc-occurs-at-the-worst-time-in-tight-loop-garbage-collection/104934/39 "2023-10-17T02:20:31Z")

</div>

Try using the allocation profiler instad of [`--trace-allocations`](https://discourse.julialang.org/t/i-cant-help-but-think-debugging-memory-allocations-shouldnt-be-this-hard/105042/2)

> [@Allan\_Baker](#):
>
> I got rid of all allocations except for the original function call in the original message that accessed the 4D array from the struct. I tried making that struct mutable and it did not matter.

Do you have a standalone MWE for that? Would make it easier to show how I analyze were allocations are coming from.

---

_[View the full topic](https://discourse.julialang.org/t/gc-occurs-at-the-worst-time-in-tight-loop-garbage-collection/104934)._
