> What actually happens is that the memory is released back to the heap > (but *not* to the OS, at least on Linux), with the result that > concatenating elements will introduce a substantial hit particularly if > space for a new element allocated from the heap isn't contiguous. Writing a preallocating wrapper *where needed* for heavily grown arrays is fairly simple.
The thing is: it's rarely worth it ;-) I recently did that for a wavefront mesh loader that appends vertices one-by-one to an array, and for a scene with some 400k vertices, the difference was just some milliseconds out of several seconds overall. Turns out the allocator usually finds a spot where the array doesn't need to actually be copied around for a while, and the pure bookkeeping of realloc is very cheap. -- Regards, Martok Ceterum censeo b32079 esse sanandam. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal