Thanks Kevin -

I actually DO use FreeAndNil. And the leak is reported without the click event 
being called.

--- In [email protected], "Kevin McCoy" <kgmcco...@...> wrote:
>
> nf4lham
> 
> Its hard to tell, just looking at the stack and your code, but my guess is 
> that your line:
> 
> if frmPKT = nil then
> 
> if not optimal, unless when you free the frmPKT, you call 
> 
> FreeAndNil(frmPKT); 
> 
> instead of 
> 
> frmPKT.Free;
> 
> Otherwise, frmPKT will point to trashed memory on the second through Nth 
> passes through your code. Bad things will happen when your code skips over 
> the if statement and starts using the pointer on future passes.
> 
> Free does NOT set the pointer to NIL. 
> 
> You could also call 
> 
> frmPKT.Free;
> frmPKT := NIL;
> 
> to do the same thing that FreeAndNil does.
> 
> HTH,
> 
> Kevin G. McCoy
> 
> 
> 
> --- In [email protected], "nf4lham" <nf4l@> wrote:
> >
> > I'm using FastMM4 with D7, and it's reporting some memory leaks I don't 
> > understand. From the report:
> > This block was allocated by thread 0x7C4, and the stack trace (return 
> > addresses) at the time was:
> > 402EBC [syste...@getmem]
> > 4B25D7 [Forms][TCustomForm.DoCreate]
> > 4B22B7 [Forms][TCustomForm.AfterConstruction]
> > 603EBD [LogBk.pas][LogBk][TfrmLog.mnuClusterClick][3935]
> > 4AB514 [Menus][TMenuItem.Click]
> > 4B4F19 [Forms][TCustomForm.Activate]
> > 49D344 [Controls][TWinControl.WndProc]
> > 49CFBF [Controls][TWinControl.MainWndProc]
> > 455256 [Classes][StdWndProc]
> > 7E418734 [Unknown function at GetDC]
> > 7E418816 [Unknown function at GetDC]
> > The block is currently used for an object of class: TDXDAliasRec
> > 
> > This is line 3935 from frmLog (main form)
> > 
> > if frmPKT = nil then
> >       frmPKT := TfrmPKT.Create(self);
> > 
> > frmPKT is freed in the close event of frmLog
> > 
> > TDXDAliasRec is created in TfrmPkt.Create and freed in TfrmPkt.FormClose.
> > 
> > SO where's the leak?
> > 
> > Thanks, Mike
> >
>


Reply via email to