# How to force an object to be freed by the garbage collector

**URL:** https://discourse.julialang.org/t/how-to-force-an-object-to-be-freed-by-the-garbage-collector/77985
**Category:** General Usage
**Tags:** memory-allocation, garbage-collection
**Created:** [March 16, 2022, 4:56pm UTC](https://discourse.julialang.org/t/how-to-force-an-object-to-be-freed-by-the-garbage-collector/77985 "2022-03-16T16:56:24Z")
**Posts on this page:** 1
**Showing post:** 20

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [October 26, 2023, 12:11pm UTC](https://discourse.julialang.org/t/how-to-force-an-object-to-be-freed-by-the-garbage-collector/77985/20 "2023-10-26T12:11:44Z")

</div>

There’s also this new possible (global) hint:

> [@GC occurs at the worst time in tight loop (Garbage Collection)](https://discourse.julialang.org/t/gc-occurs-at-the-worst-time-in-tight-loop-garbage-collection/104934/56):
>
> Did you give Julia a hint? –heap-size-hint

I hope, and have high confidence, that this hint option will get redundant though soon. Users should have to and don’t need to worry about max. memory in most cases. They may need to worry about finalizers in some cases; and _memory mapped files_ relating to that, which I believe was your original problem (not show in this example); though you didn’t use such directly, only through a package (and only a problem on Windows…).

It’s helpful to know of. Possibly in that case. I would try to see if it helps with or without that explicit GC.gc(). Or GC.gc(false).

But again, I would try Bumper.jl that solves this if you’re ok with rather trivial (local) code changes.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-force-an-object-to-be-freed-by-the-garbage-collector/77985)._
