Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-09

Destroy vs Free: Memory Leak?

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Brian Winfrey

I have a TestCase that has this issue.  If I call obj.Free, I am unable to step into the Destroy method and heaptrc indicates a memory leak.  If I call obj.Destroy everything works as expected.  Following the call to Free -
... if (obj nil) then obj.Destroy;
it would seem that the object must be nil. How can I test this? i am unable to step into objpas?.inc.

Thanks, Brian.

Reply by email

Michael Van Canneyt
to Brian Winfrey
Brian Winfrey wrote 7 lines
I have a TestCase that has this issue.  If I call obj.Free, I am unable to step into the Destroy method and heaptrc indicates a memory leak.  If I call obj.Destroy everything works as expected.  Following the call to Free - ... if (obj nil) then obj.Destroy; it would seem that the object must be nil. How can I test this? i am unable to step into objpas?.inc.

You don't need to step in ?

Replace the line Obj.Free with

   if (Obj=nil) then
     Writeln('Error')
   else
     Obj.Free;

Then you'll find the error.

To do what you want you'll need to recompiler everything (RTL, FCL, PAckages etc. with debug information (pass OPT=-gl to the make command line, maybe DEBUG=1 also works)

Michael.

Reply by email

bwCode4U

Michael,

pass OPT=3D-gl to the make command line, maybe DEBUG=3D1 also works

I don't know what this OPT is.  Where can I find out more.

Thanks,
Brian

Reply by email

Michael Van Canneyt
to bwCode4U: I don't know what this OPT is.  Where can I find out more. Brian
bwCode4U wrote 6 lines
Michael, > pass OPT=3D-gl to the make command line, maybe > DEBUG=3D1 also works I don't know what this OPT is.  Where can I find out more.

The makefile uses several variables to construct a command-line when compiling units and programs. the contents of the variable OPT is simply appended to the compiler-command-line. make all OPT=-gl
tells make to compile everything and add -gl to the compiler command-line;

You can find more info on compiling the compiler in the appendix of the programmer's manual. (or was it the user's guide ?)

Michael.

Reply by email