0
votes

Why should you always use FreeAndNil instead of Free
EurekaLog Blog
– Today I want to discuss the idea of using FreeAndNil routine instead of Obj.Free. Well, when someone talks about object creation and destruction, he usually imagine something like this: ... var SomeObj: TSomeClass; ... SomeObj := TSomeClass.Create; try ... finally SomeObj.Free; end; ... However, I want to show that you should avoid "Free" call, whenever possible - by replacing it with call to FreeAndNil, for example: ... var SomeObj: TSomeClass; ... SomeObj := TSomeClass.Create; try ... finally FreeAndNil(SomeObj); end; ... Please, note, that I mean ...
Statistics
|
Visits by Source |
User Actions |