# Inconsistent allocation with threads and function arguments in 1.12

**URL:** https://discourse.julialang.org/t/inconsistent-allocation-with-threads-and-function-arguments-in-1-12/133190
**Category:** Performance
**Created:** [October 16, 2025, 12:22am UTC](https://discourse.julialang.org/t/inconsistent-allocation-with-threads-and-function-arguments-in-1-12/133190 "2025-10-16T00:22:23Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [October 16, 2025, 9:40am UTC](https://discourse.julialang.org/t/inconsistent-allocation-with-threads-and-function-arguments-in-1-12/133190/4 "2025-10-16T09:40:56Z")

</div>

Maybe this is related and a workaround:

> [@Type-instability because of @threads boxing variables](https://discourse.julialang.org/t/type-instability-because-of-threads-boxing-variables/78395/21):
>
> Yes. You could try adding let blocks. Note that Threads.@spawn has sugar where using $ on variables automatically creates let blocks for you: julia\> @macroexpand Threads.@spawn foo($x) quote #= threadingconstructs.jl:229 =# let var"##394" = x #= threadingconstructs.jl:230 =# local var"#14#task" = Base.Threads.Task((()-\>begin #= threadingconstructs.jl:226 =# foo(var"##394") end)) #= …

---

_[View the full topic](https://discourse.julialang.org/t/inconsistent-allocation-with-threads-and-function-arguments-in-1-12/133190)._
