# CUDA.jl with @threads causing memory leak?

**URL:** <https://discourse.julialang.org/t/cuda-jl-with-threads-causing-memory-leak/136853>\
**Category:** GPU\
**Tags:** bug, multithreading, cuda, threads, cudajl\
**Created:** [April 24, 2026, 7:03pm UTC](https://discourse.julialang.org/t/cuda-jl-with-threads-causing-memory-leak/136853 "2026-04-24T19:03:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Post date:** [April 26, 2026, 9:28am UTC](https://discourse.julialang.org/t/cuda-jl-with-threads-causing-memory-leak/136853/3 "2026-04-26T09:28:42Z")

</div>

Does the multithreaded `func2` (without `CUDA.unsafe_free!` or `CUDA.reclaim`) actually run out-of-memory if you call it in a loop?

I guess you have seen this comment.

> [@CUDA memory isn't freed and cannot be backtracked](https://discourse.julialang.org/t/cuda-memory-isnt-freed-and-cannot-be-backtracked/83292/5):
>
> This is a perfectly normal report: you’re only using 5MB of GPU memory, while the underlying pool (which allocations are made in) is currently sized around 5GB, thus consuming most of the physical memory on your device. This does not mean that the memory is unavailable, you can allocate 5GB-5MB. So this isn’t indicative of an OOM, or a memory leak.

It would also be interesting to see what happens if you call `CUDA.reclaim` on all threads.

---

_[View the full topic](https://discourse.julialang.org/t/cuda-jl-with-threads-causing-memory-leak/136853)._
