Hi,
I observe an allocation involving a closure that I do not understand.
Consider the following minimal working example:
julia> function outer(a)
inner(b, c) = b, c
a, inner
end
outer (generic function with 1 method)
julia> a, inner = outer(5)
(5, inner)
julia> @allocations outer(5)
0
julia> inner(5, 8)
(5, 8)
julia> @allocations inner(5, 8)
1
julia> @allocated inner(5, 8)
32
Note that inner()
doesn’t really close over anything. Output of @code_warntype
of both, outer(5)
and inner(5, 8)
looks fine.
Is this a false positive of the @allocated
macro?
versioninfo
julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, tigerlake)
Threads: 1 on 8 virtual cores