[fpc-pascal] Array clearing
pascaldragon at googlemail.com
Thu Apr 13 17:29:01 CEST 2017
Am 13.04.2017 14:47 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
> > On Apr 13, 2017, at 7:08 PM, Mattias Gaertner <nc-gaertnma at netcologne.de>
> >> 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
SetLength *does* use a reallocate for this, but since it doesn't give you
any guarantee for its success as its the task of the memory manager to deal
with this, it's easier to assume that the array is indeed copied.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal