# Non-deallocating (permanently growing) extensible arrays

**URL:** <https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056>\
**Category:** General Usage\
**Created:** [November 13, 2019, 8:00pm UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056 "2019-11-13T20:00:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Matthews](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sean_matthews/32/8206_2.png) [@Sean\_Matthews](https://discourse.julialang.org/u/Sean_Matthews)\
**Post date:** [November 13, 2019, 8:00pm UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056/1 "2019-11-13T20:00:37Z")

</div>

[Sorry for all errors of subject subcategory, ignorance of packages, etc. - this is my first post here]

I am looking for a package implementing a vector type where once space is allocated for an expansion (using, e.g., insert! or push!) it is not deallocated again if I later use pop! or delete, but keeps the space available for the next insert.

Basically, I need to maintain a very large number of vectors of changing length and I would like to avoid very many calls to alloc.

Anybody have a recommendation for something that does this?

Thanks in advance,

Sean Matthews

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [November 13, 2019, 8:18pm UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056/2 "2019-11-13T20:18:38Z")

</div>

Welcome to the Julia forum. 🙂

PushVectors explicitly does what you’re requesting, but I believe that in general Julia does not deallocate the underlying memory if you `pop!` off of or `resize!` a vector. The only real advantage to PushVectors is that [it avoids a call into the runtime library at each usage of `push!`](https://github.com/JuliaLang/julia/issues/24909). There’s [some discussion of the performance model of `push!` and friends](https://discourse.julialang.org/t/documenting-performance-model-of-empty-sizehint-push-friends/23544) scattered about on this forum that might be helpful.

[https://github.com/tpapp/PushVectors.jl](https://github.com/tpapp/PushVectors.jl)

---

<div class="post-metadata">

**Author:** ![Sean\_Matthews](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sean_matthews/32/8206_2.png) [@Sean\_Matthews](https://discourse.julialang.org/u/Sean_Matthews)\
**Post date:** [November 16, 2019, 2:02pm UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056/3 "2019-11-16T14:02:43Z")

</div>

Thanks for that. Very helpful.

Sean

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 16, 2019, 2:13pm UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056/4 "2019-11-16T14:13:13Z")

</div>

Just use a normal `Vector`. As long as you don’t call `sizehint!` it will not reduce storage. `PushVector` is just an ugly hack to work around that `push!` is slightly slower than it has to be but unless that is a real bottle neck, just use normal `Vector `.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 16, 2019, 4:00pm UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056/5 "2019-11-16T16:00:20Z")

</div>

Yes, PushVectors is a joke gone too far. I added a warning about this.

**EDIT** also on `nightly`, `Vector` appears to be faster.

---

<div class="post-metadata">

**Author:** ![Sean\_Matthews](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sean_matthews/32/8206_2.png) [@Sean\_Matthews](https://discourse.julialang.org/u/Sean_Matthews)\
**Post date:** [November 17, 2019, 7:36am UTC](https://discourse.julialang.org/t/non-deallocating-permanently-growing-extensible-arrays/31056/6 "2019-11-17T07:36:46Z")

</div>

thanks
