Hello I have a list of type TList. I fill it with pointer to records which are created with new.
One of my coworkers told me that freeing the list will free all elements, but I have my doubts because I’m use to C. So does Delphi 7 have some sort of garbage collection and I really don’t have to free each element? Can someone explain to me how that works?
TListholds pointers, but it does not own the things they point at. It cannot, because it has no idea how you allocated them, so it cannot know how to release them, either. You need to destroy those items yourself, if they’re supposed to be destroyed.Your colleague might be thinking of
TObjectList, which can optionally own the items in the list.