Clear a TList or a TObjectList

后端 未结 5 1438
故里飘歌
故里飘歌 2021-02-19 05:33

I\'m a bit puzzled of what to use for storing objects in a list. Until now I have used TList and freed each item in a loop. Then I discovered TObjectList

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 06:14

    Really watching the TObjectList code in contnrs.pas OwnObjects does nothing. FOwnObjects is a variable declared in the private part of TObjectList that is not used anywhere in the TObjectList code (except just assigning the value), and there is no overridden Clear procedure in it.

    So I'm afraid it necessary to free the memory just the same as in TList.

提交回复
热议问题