[fpc-pascal] performance when resizing a dynamic array
mse00000 at gmail.com
Sun Dec 4 12:30:25 CET 2016
On 12/04/2016 11:39 AM, Martin Schreiber wrote:
> On 12/04/2016 11:28 AM, Graeme Geldenhuys wrote:
>> If I use an array to hold a list of say Integers. Is there any serious
>> performance penalty for resizing (growing) the dynamic array as I add
>> items. My point being, I don't know the number of elements I'll need
> The problem with enlarging big dynamic arrays is that AFAIK there always
> is a move operation of the whole existing data.
That happens with every reallocmem() with FPC memory manager so using a
getmem() block instead of a dynamic array has no advantage in this
regard. Dynamic arrays additionally call fillchar(). If fillchar() is
not necessary for unmanaged items the MSEgui functions
AllocUnInitedArray()/ReAllocUnInitedArray() can be used instead.
More information about the fpc-pascal