I am running the following routine in with --track-allocation=user
. The routine is called in a for loop. Still I am surprised at the allocation generated in the first line: I would expect numqps
to be allocated on the stack and thus not contributing to the final allocation count.
- function buildpoints{T}(cell::Cell{T}, uv)
-
2488320 numqps::Int = size(uv,2)
12607488 mps = Array(Point{T}, numqps)
0 for i in 1 : numqps
0 mps[i] = buildpoint(cell, Vector2(uv[1,i], uv[2,i]))
- end
-
0 return mps
-
- end
EDIT: A bit further along in the memory profiling output I find:
1262976 numcells(m::Mesh) = size(m.faces,2)
It seems the size
function on Arrays is implemented not very efficiently?