[fpc-pascal] Re: PChar -> AnsiString -> PChar = memory leak?

Vincent Snijders vsnijders at vodafonevast.nl
Thu Oct 29 14:11:59 CET 2009


Graeme Geldenhuys schreef:
> The reason why I'm not sure, is because I created a simple console
> test application. Initially, running the program, I got the correct
> output. Then I thought I would enable 'heaptrc' (-gh compiler
> parameter) to make sure I am not leaking memory in the application.
> Now with heaptrc enabled, I get some strange output.. :-(
> 
> So now I'm confused.
> 
> 
> ---- with heaptrc enabled------------------------
> $ ./project1
> t=hello
> Text=hello
> Text=������������ᆳ
> Heap dump by heaptrc unit
> 20 memory blocks allocated : 608/632
> 20 memory blocks freed     : 608/632
> 0 unfreed memory blocks : 0
> True heap size : 131072
> True free heap : 131072
> 
> 
> ---- Without heaptrc enabled------------------------
> tmp $ ./project1
> t=hello
> Text=hello
> Text=hello world
> 
> 
> I'm using FPC 2.3.1 (latest revision) using 64bit Linux.
> 

I guess heaptrc expose that you are looking at memory that is already freed.

Vincent



More information about the fpc-pascal mailing list