[fpc-devel] Need heap manager -gv explanation [tests]
nc-gaertnma at netcologne.de
Tue Apr 29 11:41:59 CEST 2014
On Tue, 29 Apr 2014 10:30:43 +0200
Petr Kristan <petr.kristan at epos.cz> wrote:
> > Check if you are increasing buffers in constant steps.
> > Change the increment to exponentially.
> I use "inteligent" block increasing. I can optimize program, but why is
> fpc heap manager to slow?
> base = 1000000;
> sum := GetTickCount;
> for i := 0 to 10 do begin
> ms := GetTickCount;
> for j := 1 to 9 do begin
> ReAllocMem(p1, base*(i*10+j));
> ReAllocMem(p2, base*(i*10+j));
> Writeln(Format('Grow %d-%d %dms', [base*i*10, base*(i*10+9), GetTickCount-ms]));
Reallocmen checks if there is enough free mem behind. If not it
allocates a new mem and copies the content.
The fpc heap manager allocates new mem behind the
already allocated mem. Running two Reallocmem have almost never enough
free mem behind and they have to copy often.
cmem leaves more space behind the blocks, so that calling Reallocmen
with small increases needs less copies. AFAIK the cmem algorithm depends
More information about the fpc-devel