# Memory leak when migrating from Julia 1.10.7 to 1.11.2

**URL:** <https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 24, 2024, 11:13am UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153 "2024-12-24T11:13:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gattu\_Mytraya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gattu_mytraya/32/45429_2.png) [@Gattu\_Mytraya](https://discourse.julialang.org/u/Gattu_Mytraya)\
**Post date:** [December 24, 2024, 11:13am UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/1 "2024-12-24T11:13:17Z")

</div>

Hi,  
I’m encountering a memory issue in Julia v1.11.2 with a Monte Carlo simulation. The code spans multiple files which makes it hard for me to post it here. I can say that the code doesn’t allocate new memory after the Monte Carlo simulation starts (I have checked this on my PC by monitoring the memory usage). On my PC, memory usage is stable, but on a cluster, it grows significantly (after the simulation begins), leading to OOM errors. This didn’t happen in Julia v1.10.7, where I ran the same code for over 20,000 CPU hours without issues (and the memory usage is stable once the simulation begins). What could be causing this memory leak in Julia v1.11.2, and how can I debug it?

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [December 24, 2024, 1:06pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/2 "2024-12-24T13:06:12Z")

</div>

Perhaps try taking and comparing [heap snapshots](https://docs.julialang.org/en/v1/stdlib/Profile/#Heap-Snapshots).

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [December 24, 2024, 1:26pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/3 "2024-12-24T13:26:37Z")

</div>

Sounds like [Memory leak with Julia 1.11's GC (discovered in SymbolicRegression.jl) · Issue #56759 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/56759) which was fixed by [gc: improve mallocarrays locality by vtjnash · Pull Request #56801 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/56801) which is marked for backport.

Can you try nightly?

---

<div class="post-metadata">

**Author:** ![Gattu\_Mytraya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gattu_mytraya/32/45429_2.png) [@Gattu\_Mytraya](https://discourse.julialang.org/u/Gattu_Mytraya)\
**Post date:** [December 25, 2024, 11:43am UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/4 "2024-12-25T11:43:45Z")

</div>

Thanks for pointing this out. My issue is exactly like the one in [Memory leak with Julia 1.11's GC (discovered in SymbolicRegression.jl) · Issue #56759 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/56759).

I will try to run a job with the nightly version of Julia and see if that fixes things.

---

<div class="post-metadata">

**Author:** ![Gattu\_Mytraya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gattu_mytraya/32/45429_2.png) [@Gattu\_Mytraya](https://discourse.julialang.org/u/Gattu_Mytraya)\
**Post date:** [December 26, 2024, 6:49pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/5 "2024-12-26T18:49:52Z")

</div>

The nightly version fixed the issue. Thanks.

---

<div class="post-metadata">

**Author:** ![jaredjeya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredjeya/32/47454_2.png) [@jaredjeya](https://discourse.julialang.org/u/jaredjeya)\
**Post date:** [February 13, 2025, 11:38am UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/6 "2025-02-13T11:38:02Z")

</div>

Hi, I’m experiencing something very similar with Julia 1.11.3 – I’m doing a calculation using the ITensors.jl library, and writing to files using HDF5.jl, on a university cluster (SLURM). I run a somewhat intensive function a few dozen times - but I’m finding that memory usage grows without bound (even overshooting the heap-size-hint). I’m even manually calling GC.gc() each time after calling that function.

To give an example, if I call this function once, the memory usage is ~1-2GB. After calling it about 30 times, it’s hitting 5GB, and SLURM is killing my jobs.

Can anyone help me diagnose what the issue is, please?

Edit: To add to this, using [How to track total memory usage of Julia process over time - #6 by sloede](https://discourse.julialang.org/t/how-to-track-total-memory-usage-of-julia-process-over-time/91167/6), on my computer I’m finding it’s consistently using slightly more memory after each loop. For a (much) smaller problem, it’s 10MB each time, resulting in total extra memory usage of 400MB by the end. I’m running the same diagnostics on the cluster for a bigger problem.

---

<div class="post-metadata">

**Author:** ![lupemba](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@lupemba](https://discourse.julialang.org/u/lupemba)\
**Post date:** [February 13, 2025, 12:25pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/7 "2025-02-13T12:25:35Z")

</div>

Could it be related to [Automatic h5\_garbage\_collect() garbage collection · Issue #1186 · JuliaIO/HDF5.jl · GitHub](https://github.com/JuliaIO/HDF5.jl/issues/1186)

---

<div class="post-metadata">

**Author:** ![jaredjeya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredjeya/32/47454_2.png) [@jaredjeya](https://discourse.julialang.org/u/jaredjeya)\
**Post date:** [February 13, 2025, 12:54pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/8 "2025-02-13T12:54:49Z")

</div>

Thanks! I’m not sure that solves my issue, though.

I just ran my some diagnostics on the cluster, calling the HDF5 GC function, and the memory usage was growing by hundreds of megabytes each loop (e.g. increases by 1000MB during the calculation and then only frees 300MB after it’s over). I’m not sure it could be HDF5 because the file I’m writing to is only a few MB.

It’s very possible the problem is in ITensors.jl, so I’ll probably pursue this further with them.

---

<div class="post-metadata">

**Author:** ![m4ltee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/m4ltee/32/30818_2.png) [@m4ltee](https://discourse.julialang.org/u/m4ltee)\
**Post date:** [April 8, 2025, 4:54pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/9 "2025-04-08T16:54:34Z")

</div>

Hi jaredjeya, I have a similar issue using ITensors (both in Julia 1.11.2, 1.11.4 and also 1.10.8). (How) did you solve your issue?

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [April 8, 2025, 5:41pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/10 "2025-04-08T17:41:22Z")

</div>

> [@m4ltee](#):
>
> Hi jaredjeya,

(Making sure that @jaredjeya gets pinged on this question)

---

<div class="post-metadata">

**Author:** ![jaredjeya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredjeya/32/47454_2.png) [@jaredjeya](https://discourse.julialang.org/u/jaredjeya)\
**Post date:** [April 8, 2025, 11:55pm UTC](https://discourse.julialang.org/t/memory-leak-when-migrating-from-julia-1-10-7-to-1-11-2/124153/11 "2025-04-08T23:55:48Z")

</div>

I downgraded to 1.10.9 and that seems to have significantly improved my problem, at least to the point that I’m no longer running out of memory. I’m pretty certain that it’s the Julia GC bug mentioned above which was introduced in 1.11 and will not be fixed until 1.12 (or 1.11.5), so if you’re also having issues in 1.10.x then I’m not sure what’s happening!

That being said, I haven’t done detailed diagnostics, since it is working fine for me now, so I can’t say if there’s still a (smaller) leak for 1.10.9 in my code.
