[Lazarus] Memory leak hunt request

taazz taz at evosi.eu
Sat May 3 14:29:17 CEST 2014


On 4/26/2014 12:31 PM, Reinier Olislagers wrote:
> There are still quite some leaks present, and I'd appreciate comments on
> what exactly to fix to get rid of them...

1) any steps to reproduce the leaks?
     I did run the application with trace enabled and upon exit no 
memory leaks where reported, after that I played with it a bit creating 
a couple of table views and stored procedures but I didn't get any leaks 
reported other.
When I say I got no reports I mean that the leak file (opened it from 
the leakview utility) was empty.

2) Auto created forms?
   Are all those needed to be create on startup? From a quick look I got 
the impression that they could be encapsulated in to ready made routines 
after a bit of clean up. It has a few questionable design(?) decisions 
for example it has a function in the main form
called SaveRegistrations that looks like

procedure TfmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
   if Length(RegisteredDatabases) > 0 then
     fmReg.SaveRegistrations;
   SaveAndCloseSQLHistory;
end;

and in the fmReg the saveRegistrations looks like

function TfmReg.SaveRegistrations: Boolean;
var
   F: file of TRegisteredDatabase;
   FileName: string;
   i: Integer;
begin
   try
     Sort;
     FileName:= fmMain.getConfigurationDirectory + 'turbobird.reg';

     AssignFile(F, FileName);
     FileMode:= 2;
     Rewrite(F);

     for i:= 0 to High(fmMain.RegisteredDatabases) do
       Write(F, fmMain.RegisteredDatabases[i].OrigRegRec);
     CloseFile(F);
     Result:= True;
   except
     on e: exception do
     begin
       Result:= False;
     end;
   end;
end;

and I have to ask, why it is declared in this form when everything that 
needs access to is on the main form?

If those 2 things I looked at are any indication of the code quality 
then I think that you have to spend the next 3 or 4 days cleaning up 
first before delving in to leak hunting.




More information about the Lazarus mailing list