Since we’re on this topic, I recently discovered this document in one of FB’s 
open source libraries for C++: 
https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md

It makes an interesting argument for growing arrays by a factor smaller than 2 
when resizing them so that you can reuse memory more easily. Not sure how much 
you also need to use a custom malloc routine to get the benefits being claimed, 
though.

 — John

On Sep 7, 2014, at 11:38 AM, Kevin Squire <kevin.squ...@gmail.com> wrote:

> More specifically, the underlying array size starts at 16 elements and 
> doubles whenever it grows beyond it's underlying size. (This might change 
> when the array gets large, but I haven't looked at that code recently, so I 
> forget the details.)
> 
> Cheers,
>    Kevin
> 
> On Sunday, September 7, 2014, John Myles White <johnmyleswh...@gmail.com> 
> wrote:
> It gets expanded in chunks.
> 
>  — John
> 
> On Sep 7, 2014, at 10:15 AM, Steven Sagaert <steven.saga...@gmail.com> wrote:
> 
> > When you start with an empty array and grow it one element at a time with 
> > push!, does the underlying array memory block get copied & expanded by one 
> > or in larger chunks (like ArrayList in Java)?
> 

Reply via email to