# Trying to understand allocations while creating vectors

**URL:** <https://discourse.julialang.org/t/trying-to-understand-allocations-while-creating-vectors/44512>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 7, 2020, 4:46pm UTC](https://discourse.julialang.org/t/trying-to-understand-allocations-while-creating-vectors/44512 "2020-08-07T16:46:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [August 7, 2020, 4:46pm UTC](https://discourse.julialang.org/t/trying-to-understand-allocations-while-creating-vectors/44512/1 "2020-08-07T16:46:18Z")

</div>

On my laptop it appears that creating a `Vector{Float64}` with \>2048 elements triggers an extra allocation

```julia
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
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)?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [August 7, 2020, 5:15pm UTC](https://discourse.julialang.org/t/trying-to-understand-allocations-while-creating-vectors/44512/2 "2020-08-07T17:15:22Z")

</div>

It’s just an internal implementation detail.
