try finally block around every Object.Create?
Posted
by max
on Stack Overflow
See other posts from Stack Overflow
or by max
Published on 2010-05-27T16:35:53Z
Indexed on
2010/05/27
16:41 UTC
Read the original article
Hit count: 129
delphi
Hi, I have a general question about best practice in OO Delphi. Currently, I but a try finally block around everywhere, where I create an object, to free that object after usage (to avoid memory leaks). E.g.:
aObject := TObject.Create;
try
aOBject.AProcedure();
...
finally
aObject.Free;
end;
instead of:
aObject := TObject.Create;
aObject.AProcedure();
..
aObject.Free;
To you think, it is good practice, or too much overhead? And what about the performance?
© Stack Overflow or respective owner