Memory usage reported by varinfo()

Hi I understand that for a vector a

b = a

makes b refer to a

But this is my lack of understanding, why then does varinfo() show that b occupies the same amount of memory as a?

julia> a = ones(2)
2-element Array{Float64,1}:
 1.0
 1.0

julia> b = a
2-element Array{Float64,1}:
 1.0
 1.0

julia> InteractiveUtils.varinfo()
name                    size summary
---------------- ----------- --------------------------
Base                         Module
Core                         Module
InteractiveUtils 162.930 KiB Module
Main                         Module
a                        56 bytes 2-element Array{Float64,1}
ans                    56 bytes 2-element Array{Float64,1}
b                        56 bytes 2-element Array{Float64,1}

This is not a correct understanding. Both a and b refer to the array that is stored somewhere in memory. a doesn’t own this array anymore than b. In fact, there is no way you can tell the difference between a and b.

This might be useful: Converting a Matlab code into Julia - #18 by kristoffer.carlsson

1 Like

Thanks, that’s what I suspected.

My confusion stems from the usage of the term ‘refer.’ To clarify the source of my confusion, if we use Futures (remote references) or DistributedArrays, then it is very clear from varinfo() that the data being distributed or referred to are not on the process that defines the DistributedArray or Future.