Should I put a try-finally block after every Object.Create?
- by max
I have a general question about best practice in OO Delphi. Currently, I put try-finally blocks anywhere 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;
Do you think it is good practice, or too much overhead? And what about the performance?