You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For me It must to be like: (pay attention to try...finally block)
procedure TfmQueryWindow.tbCommitRetainingClick(Sender: TObject);
var
QT: TQueryThread;
begin
QT := TQueryThread.Create('commitret');
try
QT.Trans:= SqlTrans;
QT.Resume;
repeat
application.ProcessMessages;
until QT.fTerminated;
if QT.Error then
ShowMessage(QT.ErrorMsg)
else
begin
// Call OnCommit procedure if assigned, it is used to refresh table management view
if OnCommit <> nil then
OnCommit(self);
OnCommit:= nil;
end;
finally
QT.Free;
end;
end;
I mean, the consuption of resources (objects, read files, etc) must be protected for a try...finally block. If anything fail inside this block, We need to ensure that the memory will be freed.
Let me know your opinion.
Regards.
Maxi.
The text was updated successfully, but these errors were encountered:
That's right, I've added try finally to commit, rollback procedures, but the code needs refactoring to make it easy to find memory leaks. Lazarus still has some issues regarding refactoring.
Hi
I was reviewing some code and I can see several memory leaks that can happen.
I have not used FreePascal but I have used Delphi from almost 15 years and I can see thing like this: https://github.com/motaz/turbobird/blob/master/querywindow.pas#L693
For me It must to be like: (pay attention to try...finally block)
procedure TfmQueryWindow.tbCommitRetainingClick(Sender: TObject);
var
QT: TQueryThread;
begin
QT := TQueryThread.Create('commitret');
try
QT.Trans:= SqlTrans;
QT.Resume;
repeat
application.ProcessMessages;
until QT.fTerminated;
finally
QT.Free;
end;
end;
I mean, the consuption of resources (objects, read files, etc) must be protected for a try...finally block. If anything fail inside this block, We need to ensure that the memory will be freed.
Let me know your opinion.
Regards.
Maxi.
The text was updated successfully, but these errors were encountered: