[fpc-pascal] Issuchmemorystatisticspossible?

Ludo Brands ludo.brands at free.fr
Mon Aug 22 16:48:13 CEST 2011


> 
> Ludo, the patch looks very promising, I just found one 
> problem. I have a test fragment in my form (in a simple 
> simplest application)
> 
> procedure TForm1.FormCreate(Sender: TObject);
> var
>   a: integer;
> begin
>   a:=1;
>   GetMem(fTest, 1024*1024);
>   GetMem(fTest2, 1024*1024);
> end;
> 
> The previous version of the monitor showed TFORM1_FORMCREATE 
> as a source of 2M, currently there is no such symbol in the 
> list. The frame is definitely created so there should be no 
> problem with the absence of one.
> 

The problem is a missing stack frame. The caller (TFORM1_FORMCREATE) has a
stackframe but the callee (GetMem) doesn't. 

In other words: the address below the frame is the address of the caller. To
find the caller, the callee has to have a stackframe.

Attached a patch for missing stack frames. This doesn't solve all cases but
most. The const MAXFAILS could be made higher but that is again running the
risk of getting false positives. The reason for having maxfails is that a
lot of valid addresses are outside the main program area. Your testcase is
an example.

Ludo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uProcMemStat.diff
Type: application/octet-stream
Size: 2859 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110822/8afbfab4/attachment.obj>


More information about the fpc-pascal mailing list