[fpc-devel]Memory consumption

Jonas Maebe jonas at zeus.rug.ac.be
Thu Jun 27 13:59:53 CEST 2002


On donderdag, juni 27, 2002, at 12:36 , Zbigniew KuczbaƄski wrote:

> var
>   szDevNbr      : array[0..255] of Char;
>   sDevName      : String;
> begin
> { This is testing program. Unit HEAPTRC shows, that is memory leakage.
>    I really don't know why??????
> }
> //  SetHeapTraceOutPut('PCLH8.mem');
>     sDevName:='A testing string';
>     StrPCopy(szDevNbr,sDevName);
>     writeln('szDevNbr: ',szDevNbr);
>     writeln('szDevName: ',sDevName);
>
>   Halt(0);
> end.

The reason is that because of the halt() statement, the temporary 
ansistrings that have been generated can't be released. It's strange 
that a temporary ansistring is generated though. It's for the 
"StrPCopy(szDevNbr,sDevName);" statement. sDevName is a normal 
shortstring, but the compiler insists on first converting it to an 
ansistring and then uses the strpcopy(pchar,ansistring) routine (instead 
of just calling strpcopy(pchar,shortstring). Strange.


Jonas





More information about the fpc-devel mailing list