[fpc-devel] Need heap manager -gv explanation [tests]

Petr Kristan petr.kristan at epos.cz
Tue Apr 29 12:13:48 CEST 2014


On Tue, Apr 29, 2014 at 11:41:59AM +0200, Mattias Gaertner wrote:
> 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?
> >[...]
> > const
> >   base = 1000000;
> > begin
> >   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));
> >     end;
> >     Writeln(Format('Grow %d-%d %dms', [base*i*10, base*(i*10+9), GetTickCount-ms]));
> >   end;
> 
> 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
> on OS.
Is possible to tune this space behind the blocks?

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401    Czech Republic (Eastern Europe)
fax: +420 461101481



More information about the fpc-devel mailing list