Title: Message
Exception decends from TObject. Correct me if I am wrong, but if I create an exception and do not raise it, I then have to free it? But if I create an exception, muck about with it, and then raise it I do not have to free it?
 
 
 
Is the below code a memory leak?
 
procedure TSam.Samuel;
var
  e: Exception;
begin
  e := Exception.Create('Foobar');
end;
 
Is the below code okay?
 
procedure TSam.TrySamuel;
var
  e: Exception;
begin
  e := Exception.Create('Foobar');
  try
    //do some stuff
  finally
    e.Free;
  end;
end;

Reply via email to