Hi,
I have a question regarding some allocation in my code I would like to get
rid of.
I am memory mapping a file (which could be very large) which is part of a
complex 3D matrix, and then put its contents into the preallocated matrix
along the second dimension. I need the counters because the contents of
file are only a subset of the full matrix.
Here's a profiled snippet, where the file which is loaded has 120619520
bytes.
153705063 mat = Array{Complex64}(dims...)
4721282 file = Mmap.mmap(filename, Array{Complex64,2},
(dims[2],length(counter1)))
16 for i = 1:length(counter1)
148179531 mat[counter1[i],:,counter2[i]] = file[:,i]
- end
Why does the code allocate so much memory inside the for-loop (even more
bytes than the contents of file)?
It seems like this is a trivial matter, right now I just can't get my head
around it, any help is appreciated :)
Thanks,
Tim