Jump to content

must i "free" sub-components of a component?


erich.wanker

Recommended Posts

Hi .. basic delphi question .. but i am not sure at this moment:

must i "free" sub-components of a component?

   

i create in a loop (while not table.eof do begin..) something like this:

object_counter:=object_counter+1;

objekt[object_counter] := TUniPanel.Create(self);   
objekt[object_counter].Parent := UniContainerPanel1; <- the UniContainerPanel is the basic Parent of all "objekt" created Controls


    objekt_bild[object_counter]:= TUniImage.Create(self);
    objekt_bild[object_counter].Parent :=objekt[object_counter]; <- the objekt is the parent

    objekt_text[object_counter]:= TUnilabel.Create(self);
    objekt_text[object_counter].Parent :=objekt[object_counter] <- the objekt is the parent;

    objekt_text_1[object_counter]:= TUnilabel.Create(self);
    objekt_text_1[object_counter].Parent :=objekt[object_counter]; <- the objekt is the parent

    objekt_text_2[object_counter]:= TUnilabel.Create(self);
    objekt_text_2[object_counter].Parent :=objekt[object_counter]; <- the objekt is the parent

 

if i write objekt[x].free   -> are the objekt_bild, objekt_text, objekt_text_1, objekt_text_2  destroyed automaticaly ????

Link to comment
Share on other sites

12 hours ago, erich.wanker said:

destroyed automaticaly ????

 

12 hours ago, erich.wanker said:

TUniImage.Create(self);

self - this is a owner.

when owner is free then uniimage free too.

Your question is not about unigui, your question is about Delphi.

Difference between Owner and Parent in Delphi http://theprofessionalspoint.blogspot.com/2014/08/difference-between-owner-and-parent-in.html

Link to comment
Share on other sites

i create and free a lot of times ... i have anxiety that someting could go wrong Serverside with memory  if 1000 users are working with this ??

now i made:

objekt[object_counter] := TUniPanel.Create(self);   
objekt[object_counter].Parent := UniContainerPanel1; 


    objekt_bild[object_counter]:= TUniImage.Create(objekt[object_counter]); <- the owner is now the created TUniPanel
    objekt_bild[object_counter].Parent :=objekt[object_counter]; 

 

if i write objekt[x].free   -> everything what is created for this control should be set free - or ?

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...