[lazarus] Pattern found!

michael at tfdec1.fys.kuleuven.ac.be michael at tfdec1.fys.kuleuven.ac.be
Sun Aug 22 18:35:29 EDT 1999




On Sun, 22 Aug 1999, Markku Niskanen wrote:

> I have done a lot of testing with the heap functions and now I suspect
> I have found a pattern in the getmem/StrAlloc and Freemem/StrDispose
> problems.
> 
> Just run the following code and reserve heap memory
> starting from 100 bytes and up. You can comment/uncomment
> the Getmem/StrAlloc and Freemem/StrDispose lines to
> check both pairs of memory functions.
> 
> I get four values with a memory leak of 4 bytes and four values
> with zero memory leak. Has this something to do with the 64-byte
> allocation alignment or what?

1) There recently was a bug in the delphi-like memory allocator;
   this was solved.

2) the output of your program is the following:

home: >testm
Bytes to reserve: 1000
Mem             : 262112
After StrAlloc  : 261104(-1008)
After strPcopy  : 261104(-1008)
After strDispose: 262112(-0)
Bytes to reserve: 100 
Mem             : 262112
After StrAlloc  : 262000(-112)
After strPcopy  : 262000(-112)
After strDispose: 262112(-0)
Bytes to reserve: 0

Is this now correct or wrong ? Seems OK to me ?

The fact that it reserves 8 bytes more is a consequence of the old-style
calls in sysutils, combined with the new delphi-style memory manager
automatically used if you use delphi or objfpc mode. 
This will be again reduced to 4 ASAP.

Michael.






More information about the Lazarus mailing list