On my laptop it appears that creating a Vector{Float64}
with >2048 elements triggers an extra allocation
julia> @btime Vector{Float64}(undef, 2048);
379.093 ns (1 allocation: 16.13 KiB)
julia> @btime Vector{Float64}(undef, 2049);
454.149 ns (2 allocations: 16.14 KiB)
julia> sizeof(Float64)*2048
16384
Something similar is seen with eltype ComplexF64
julia> @btime Vector{ComplexF64}(undef, 1024);
403.270 ns (1 allocation: 16.13 KiB)
julia> @btime Vector{ComplexF64}(undef, 1025);
478.369 ns (2 allocations: 16.14 KiB)
I’m not familiar with how allocations occur, could someone please explain why this extra allocation takes place once we overshoot a certain memory limit (16.13 KiB in this case)?