# Doubly linked objects preventing garbage collection

**URL:** <https://discourse.julialang.org/t/doubly-linked-objects-preventing-garbage-collection/105326>\
**Category:** General Usage\
**Created:** [October 23, 2023, 7:22pm UTC](https://discourse.julialang.org/t/doubly-linked-objects-preventing-garbage-collection/105326 "2023-10-23T19:22:54Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [October 24, 2023, 4:05pm UTC](https://discourse.julialang.org/t/doubly-linked-objects-preventing-garbage-collection/105326/5 "2023-10-24T16:05:11Z")

</div>

You can try again with `GC.gc(true)` to force a full garbage collection. But generally you should never rely on finalizers to run. Recent thread on a similar topic:

> [@Can I mimick finalizing for immutables / is an immutable file handler unfeasible?](https://discourse.julialang.org/t/can-i-mimick-finalizing-for-immutables-is-an-immutable-file-handler-unfeasible/104687/1):
>
> I can’t think of other uses for destructors/finalizers in a language without manual deallocations, so I’m using file-closing as an example. It seems to me that I could implement open to open a file and construct an immutable file descriptor, then implement a close to use the file descriptor to close the file. However, my concern is that the file descriptor isn’t handled by the garbage collector, so unlike the typical IOStreams with finalizer(close, x), the file won’t be automatically closed when…

Memory issue can also arise from different things. Julia 1.9 changed GC heuristics and as a result many people experience memory issues. If you haven’t already you should give Julia [a hint with --heap-size-hint](https://github.com/JuliaLang/julia/blob/bed2cd540a11544ed4be381d471bbf590f0b745e/NEWS.md?plain=1#L50C51-L50C51) and see if things improve.

---

_[View the full topic](https://discourse.julialang.org/t/doubly-linked-objects-preventing-garbage-collection/105326)._
