[fpc-pascal] TFPList.Expand was: Maximum of memory which can be used by single program in 32 bit Windows
Michael Van Canneyt
michael at freepascal.org
Fri May 20 14:41:34 CEST 2016
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.
More information about the fpc-pascal
mailing list