On Fri, 20 May 2016, OBones wrote:
Lukasz Sokol wrote:
On 20/05/16 09:40, Graeme Geldenhuys wrote:
On 2016-05-20 09:36, Graeme Geldenhuys wrote:
I think a “x percentage of capacity” increment is the way to go. eg: 5
or 10%
Scrap that idea. In hind sight, % increments is what is causing the
problem.
Regards,
Graeme
And actually why not 'just' allocate exactly what is needed on demand ? May
be slower but
even less overhead.
Because Grow is called once for every item added. And if you add
thousands of items, the cost of allocating 4 more bytes at a time and
maybe moving the memory all the time is extremely high.
This is why a balance needs to be found between the allocation frequency
and the memory over usage cost, and also why you should always set
Capacity to a plausible value before filling the list.
Exactly.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal