Leo
 
Why all the pointers!

var myObject : TMyObject;
begin 
  MyObject := tMyObject.create; 
  MyStringGrid.Objects[Col,Row] := MyObject;

and  TMyObject(MyStringGrid.Objects[Col,Row]).free;

does the same thing

Regards
Neven
----- Original Message -----
Sent: Friday, 19 November 1999 12:46
Subject: Re: [DUG]: Looking for memory leaks

Progress report.
I tried Memproof, as someone in DUG suggested, but it found very little for me.

So I tried Turbopowers memory sleuth on Terry's recommendation. They have a time limited eval version. Boy its good, I was routinely leaving undisposed memory all over the place, mainly because I was dumb and lazy, but Memory Sleuth at least allowed me to see it.

I found one really curious thing though - I was creating an object which I had defined thus;
pMyObject = ^tMyObject;
tMyObject = class
...
end;

I created objects and saved them in a StringGrid;

var myObject : pMyObject;
begin
  new(myObject);
  MyObject^ := tMyObject.create;
  MyObject^.Methodcalls
  MyStringGrid.Objects[Col,Row] := MyObject;

then I disposed of the object in the end;

  tMyObject(MyStringGrid.Objects[Col,Row]).free;
  dispose(MyStringGrid.Objects[Col,Row])

TurboSleuth reported an undisposed memory from the new line. When I recoded to use a tMyObject instead of a pMyObject (and dropped the associated new and dispose calls) the leak disappeared. I am more clever now, though no wiser. Any insights or explanations?

Leo

Turbopower have 'Memory Sleuth' which I've found to be very good. Some $
involved though.

Terry

>hi all
I am trying to find sources of memory leaks in my code. Can anyone offer
advice,
or perhaps recommend a free or cheap tool to use.

Leo Ramakers
<

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

--------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz

Reply via email to