Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Deleting objects from a TList


This question is answered.


Permlink Replies: 1 - Last Post: Sep 23, 2016 8:44 AM Last Post By: Peter Below
Toby Dobbs

Posts: 77
Registered: 9/24/16
Deleting objects from a TList  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 23, 2016 2:53 AM
When removing an item from a TList of objects, via the Delete() method, what is the best way of freeing the object so as to avoid a memory leak?
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Deleting objects from a TList
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 23, 2016 8:44 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Toby Dobbs wrote:

When removing an item from a TList of objects, via the Delete()
method, what is the best way of freeing the object so as to avoid a
memory leak?

The best way is to use a TObjectlist instead, since it will (by
default) manage the lifetime of the objects you add to it.

--
Peter Below
TeamB
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02