[fpc-pascal] Effective memory allocation

Xiangrong Fang xrfang at gmail.com
Mon Nov 3 08:36:45 CET 2014

2014-11-03 14:39 GMT+08:00 Sven Barth <pascaldragon at googlemail.com>:

> Would you mind to show the timings that you got for FillChar? :)

​Using FillChar is always about 5% (or less) faster than FillQWord when
used with GetMemory, but will be around 20%-40% faster if the memory is
allocated by SetLength.

Additionally this switch won't help you. The memory buffer that is
> allocated by SetLength is also allocated using GetMemory. So the buffer
> itself *is* aligned. But you don't get the start byte of the buffer in case
> of SetLength, but the first byte after the information record which might
> not be aligned correctly and *no* compiler switch will help you with that.

​Then the problem remains with SetLength vs. GetMemory... Why SetLength is
about 10000x (!) slower than GetMemory?​

​allocating 1G memory took about 0.1 second by SetLength​, but is about
1E-5 via GetMemory.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141103/105d6cc1/attachment.html>

More information about the fpc-pascal mailing list