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

Potential memoryleak in pptmplat unit with FModifiedNames TStringlist

edited August 2004 in RAP
Hi

I am getting some memory leaks in the RB7 pptmplat unit with the Freeing of
FModifiedNames (TStringList) instances.. There is no logic present either
in the TppTemplate.Destroy method nor in the TppTemplate.LoadFromStream
procedure to clean up any objects which might off been assigned to the
FModifiedNames object.

Anybody else found this problem? Or am i missing something?
I guess i have to change the logic myself?
What is the procedure for logging bugs with Report Builder 7 source.??

Thanks

Comments

  • edited August 2004

    The FModifiedNames TStringList object is created in the the
    TppTemplate.LoadFromStream and destroyed in the try..finally block in that
    same method. The purpose of the StringList is to track object references
    that are renamed during the report template process. The objects stored to
    the FModifiedNames list are used as references to the report objects.
    FModifiedNames should not free the object - those objects are part of the
    report layout that is loaded.

    There are no known memory leaks in ReportBuilder 7.04. However, if you think
    you have found a new leak, please create a simple example project using
    standard Delphi components and ReportBuilder. Email in zip format to
    support@digital-metaphors.com and we can check it out here.



    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2004
    Thanks for the reply..

    I agree that should NOT free the objects as they report components but the
    code should setting the object references in the FModifiedNames to nil
    before freeing
    FModifiedNames itself and it appears it is not causing my memory manager to
    report the leaks.

    Below is a the actual RB7 code but only with the relevant code in it related
    to the problem. I have added some comments to describe the problem

    procedure TppTemplate.LoadFromStream(aStream: TStream);
    // Some vars
    begin
    // some other lines before
    FModifiedNames := TStringList.Create;
    //// So FModifiedNames is not freed if Loadstart = false
    if not LoadStart then Exit;
    try
    // Some other code
    finally
    // some other lines
    // Code i have added to my Report builder 7.04 ppTmplat unit)

    if Assigned (FModifiedNames) then
    For X := 0 to FModifiedNames.Count-1 do
    FModifiedNames.Objects[X] := nil;

    // End of my code changes

    FModifiedNames.Free;
    FModifiedNames := nil;
    end

    As you can tell it means that FModifiedNames does not get freed if Loadstart
    = False which also causes a memory leak as the detroy method of TppTemplate
    does not seem to clean up a rogue FModifiedNames instance.

    Of course this observation is based on my 7.04 version of the ppTmplat
    unit..

    Thanks again for your time and reply..

    Edwin
  • edited August 2004

    Sorry for not responding sooner. Thanks for pointing that out the flaw.
    Looks like the code needs to modified so that the ModifiedNames object is
    created after the Exit code.

    example:

    if not LoadStart then Exit;

    FModifiedNames := TStringList.Create;

    We will create a patch source file that contains this change and will
    incorporate it into the future code base....




    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.