Questions about memory allocation

I ran julia with --track-allocation=user, and found some large memory allocations that I can’t understand. Can anyone please help explain?

  1. What is going on with the for statement here:
        - function AtomValues(spec::Array{Float64,1}, attr::Attibutes, atom::Function,
        -                        iEnd=attr.len)
227767586     for i=1:iEnd
        0         spec[i] = atom(attr, i)
        -     end
        0     nothing
        - end
  1. What is happening with the if statement here? Sys is a “mutable struct”
        - function A_SCC_TB(i::Int, sys::Sys)
1821552352     if sys.csign == sys.Cond[i]
        -             ProcessE(sys, i)
         -     end
        0     nothing
        - end

Answer for 2): it was due to type mismatch. sys.csign was declared as ::Int64, and sys.Cond was declared as ::Array{Int64}. The latter needs to be changed to ::Array{Int64,1}, and then the allocation number becomes 0.

I would expect that atom and ProecessE are allocating memory here. Have you checked these functions separately (eg with @btime)?

Actually, in atom (a 1-line function that computes a value), there is no allocation. And in ProcessE, there are some minor allocations which don’t add up to the large number on the if statement.