I am trying to understand memory management a little better. I have the following example code:
begin
mutable struct SimplestStruct
a::Float64
end
function SimplestLoop!(a::Array{SimplestStruct, 1}, x::Float64)
for i in 1:length(a)
@inbounds a[i].a = x
end
end
simples = fill(SimplestStruct(rand()), 100)
@time SimplestLoop!(simples, 6.0)
end
As far as I can work out from the docs + various good posts around about in-place operations, SimplestLoop! should operate on its first argument without allocating any extra memory. However, @time reports 17k allocations.
Is there an obvious reason why this is happening?
Thank you in advance!