[fpc-pascal] Effective memory allocation

Bruno Krayenbuhl kraybruno at bluewin.ch
Mon Nov 3 10:11:41 CET 2014


My results :

_Ptr:=GetMem(100000000)        18 mus, 824 ns / GetMem
_Ptr:=GetMem(100000000) + FillChar(_Ptr^,100000000,0)); 81 ms / GetMem + FillChar

var
  ArInt:array of int32;
.
SetLength(ArInt, 100000000 shr 2);         81 ms / SetLength

All timings are variable within [time, time+8%] on repeated runs as is generally the case for system timings.

SetLength 0's (Internally calls FillChar) the array ArInt so to do a identical comparison you need to add the FillChar to the GetMem if it is your intention to 0 the array before using it.

You have to compare things that do the same thing in the end.

Tested on XP Pro Win32 Sp3
Intel Core 2CPU
6400 #@ 2.13GHz
2.05 GHr., 1.00 Gb RAM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141103/219651a7/attachment.html>


More information about the fpc-pascal mailing list