[fpc-pascal] Array clearing

Ryan Joseph ryan at thealchemistguild.com
Thu Apr 13 14:15:13 CEST 2017


> On Apr 13, 2017, at 7:08 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> 
>> as I understood from (http://wiki.freepascal.org/Dynamic_array<http://wiki.freepascal.org/Dynamic_array>), SetLength will create a copy of the array and free the memory of the shorter array. In this case, a lot of memory operations and copy operations are performed thus degrading the performances of the code.
> 
> Correct.

Why is it copying the array and freeing instead of resizing the existing block (realloc)? That sounds crazy but I don’t know how memory managers work.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list