Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Frame ownership and memory management



Permlink Replies: 2 - Last Post: Jan 30, 2018 12:55 PM Last Post By: Alexandre Machado
Joel Zimmer

Posts: 68
Registered: 9/24/01
Frame ownership and memory management
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 2:18 PM
If I create a cgframe on a form using self as the owner do I need to make sure and free this object? Or will it automatically be freed when the form is destroyed?

For example

FdlgUploadTicket := TIWCGJQFrame.Create( self );
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Frame ownership and memory management
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 3:50 PM   in response to: Joel Zimmer in response to: Joel Zimmer
I would free it in the OnDestroy event for the form. That's the only way to ensure that everything gets cleaned up.
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: Frame ownership and memory management
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 30, 2018 12:55 PM   in response to: Joel Zimmer in response to: Joel Zimmer
Joel Zimmer wrote:
If I create a cgframe on a form using self as the owner do I need to make sure and free this object? Or will it automatically be freed when the form is destroyed?

For example

FdlgUploadTicket := TIWCGJQFrame.Create( self );

It will be destroyed by the form, because that's how TComponent ownership chain works. You can, however, free it yourself before (e.g. inside OnDestroy), but it is not required.
You can also Create it as TIWCGJQFrame.Create(nil) but then freeing it in OnDestroy becomes mandatory.

Kind regards
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02