Besides Julia internals, I suppose there is memory overhead in terms of the structure holding the array itself (when temporaries are created). I suppose an array isn't just the size in bytes of the data it holds, but also information about its size/type/etc. Though I doubt that would add up to 800 bytes, it could explain part of it.
I wonder if there is a way within julia to know the 'real' size of a julia object. El martes, 29 de abril de 2014 11:32:21 UTC+2, Carlos Becker escribió: > > I just saw another part of your message, I am wondering also why memory > consumption is so high. > > El martes, 29 de abril de 2014 11:31:09 UTC+2, Carlos Becker escribió: >> >> 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? >>> >>