This is likely to be because Julia is creating temporaries. This is probably why you get increasing memory usage when increasing array size.
This is a long topic, that will have to be solved (hopefully soon), I had a previous question related to something similar here: https://groups.google.com/d/topic/julia-users/Pbrm9Nn9fWc/discussion El martes, 29 de abril de 2014 08:05:17 UTC+2, John Aslanides escribió: > > I'm aware that evaluating a vectorized operation (say, an elementwise > product of two arrays) will result in the allocation of a temporary array. > I'm surprised, though, at just how much memory this seems to consume in > practice -- unless there's something I'm not understanding. Here is an > extreme example: > > julia> a = rand(2); b = rand(2); > > julia> @time a .*= b; > elapsed time: 0.505942281 seconds (11612212 bytes allocated) > > julia> @time a .*= b; > elapsed time: 1.4177e-5 seconds (800 bytes allocated) > > julia> @time a .*= b; > elapsed time: 2.5334e-5 seconds (800 bytes allocated) > > 800 bytes seems like a lot of overhead given that a and b are both only 16 > bytes each. Of course, this overhead (whatever it is) becomes comparatively > less significant as we move to larger arrays, but it's still sizeable: > > julia> a = rand(20); b = rand(20); > > julia> @time a.*= b; > elapsed time: 1.4162e-5 seconds (944 bytes allocated) > > julia> @time a.*= b; > elapsed time: 2.3754e-5 seconds (944 bytes allocated) > > Can someone explain what's going on here? >