Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Free object memory 1

Status
Not open for further replies.

bbegley

Programmer
Apr 29, 2002
228
US
We have a class:

T_FBPageCanvas = class
private
FCanvas:TCanvas;
FItem :T_FBItem;
FOwner :T_FBForm;
public
constructor Create(AOwner:T_FBForm);
function PaintItem(ASTR_ItemType:string):boolean;
function SetItemProperty:boolean;virtual;
end;

We have to create the FCanvas and other objects (delphi does not do this for us).

The question is, when we Free T_PageCanvas, are we freeing the "owned" objects as well (is delphi doing this for us) or do we have to do it. If we have to do it, is it appropriate for us to override the TObject.Destroy and handle it there?

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Yes - you override the destroy method and free the objects you created...

in the class...
public
constuctor Create(AOwner...);
destructor Destroy; override;
...

T_FBPageCanvas.Destroy; override;
begin
Free.FCanvas;
Free.FItem;
Inherited;
end;

 
Thanks
Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top