Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Summary of memory leaks found and corrected in RB 6.03

edited June 2003 in General

Hi,

Instead trying to create a minimal test case and make you correct the
leaks here are the leaks I have found with MemCheck,

(http://v.mahon.free.fr/pro/freeware/memcheck/)

and the fixes. Please double check if these still exists in version 7.X
and if version 6 gets updated, please incorporate the changes.

The first two leaks were definitely significant when using a data
dictionary. They were quite hard to debug because there are many TList
and TStringList's being assigned objects and sometimes ownnwership is
transfered from list to list. I have tested these corrections and all is
running fine.

Please see below for leaks and corrections. The number is my internal
change request number, just remove it.

Best regards,

Michel

--

1. Added the following routine at the beginning of the implementation
section in daMetaData.Pas

{ #3561 Free the objects stored in a string list }
procedure FreeObjectsInStringList( const Strings : TStrings );
var
Index : Integer;
begin
for Index := 0 to (Strings.Count -1) do
TObject(Strings.Objects[Index]).Free;
end;

2. At the end of TdaMetaData.ValidateTableNames,

{ #3561 lSessionTables has been assigned some objects which must be
destroyed to prevent memory leak }
FreeObjectsInStringList(lSessionTables);

lSessionTables.Free;

end; {procedure, ValidateTableNames}

3. At the end of TdaMetaData.ValidateFieldNames,

{ #3561 lDataSetFields has been assigned some objects which must be
destroyed to prevent memory leak }
FreeObjectsInStringList(lDataSetFields);

lDataSetFields.Free;

end; {procedure, ValidateFieldNames}

4. Added a try/finally block in ppEngine.TppEngine.RequestPage to
prevent a memory leak when an exception is raised in the data pipeline.
There should definitely be more try/finally's, but this is one I spotted
that cause a memory leak in my situationi.

{save current record position}
DataPipelineStateToRec(Report.DataPipeline,
FRestoreMasterDataPipelineState);


DataPipelineStateToRec(TppBandedReport(Report).DetailBand.DataPipeline,
FRestoreDetailDataPipelineState);

{ #3651 Use try/finally to prevent memory leak on exception }
try
....
finally
{restore previous record position}
DataPipelineRecToState(FRestoreMasterDataPipelineState,
Report.DataPipeline, True{aFreeBookmark});
DataPipelineRecToState(FRestoreDetailDataPipelineState,
TppBandedReport(Report).DetailBand.DataPipeline, True{aFreeBookmark});
FreeRestoreBookmarks;
end;

Comments

  • edited June 2003
    Hi Michel,

    Thanks for your help, we will research these leaks and get back to you asap.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2003
    Hello Michel,
    Which runtime/design time packages did you have to recompile?

    Did anyone from DM confirm these memory leaks yet for the version 603?

    Thanks




This discussion has been closed.