Leo
 
I'm not quite sure what you mean by 'I guess that Delphi doesnt properly dispose of object pointers that have been 'dispose'd though'
 
You should also add

MyStringGrid.Objects[Col,Row] := nil;

after the free

Regards

 

----- Original Message -----
Sent: Monday, 22 November 1999 11:31
Subject: Re: [DUG]: Looking for memory leaks

Neven MacEwan wrote:
Why all the pointers!
thanks for the 'pointer'. I had taken the example in the help for tList.items literally and propogated the pointer use through my work, but of course they used a record rather than an object and were forced to use new etc. I have simplified my code considerably after your suggestion, thanks. (I guess that Delphi doesnt properly dispose of object pointers that have been 'dispose'd though).

Regards
Leo

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

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

does the same thing

RegardsNeven
----- 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
--------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz

Reply via email to