0
votes
Vote UpVote

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 ...
Favorite? Off-Topic? Alex @ 2010-11-26 14:52

Statistics

Visits: 71
Votes: 0
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)