How do the interface-based collections in spring4d handle the lifecycle of their elements? What I would like to achieve is that when the collection gets out of scope, the containing objects are also freed, and their destructors called. Not sure this is the case at the moment.
The TCollections
class offers a number of class methods to create new collections. These methods provide parameters that allow you to specify how the member lifetime is to be handled.
CreateDictionary
and CreateMultiMap
have an ownerships
parameter that allows you to specify that the keys, or values, or both are owned by the collection.CreateList
, CreateObjectList
, CreateSortedList
, CreateSortedObjectList
, CreateQueue
and CreateStack
have an ownsObjects
parameter that determines whether or not the collection owns its members.