FastMM4 says “The block header has been corrupted”

后端 未结 4 542
后悔当初
后悔当初 2021-02-06 12:32

I had this nasty bug that disappeared in the past but now after quite some time it returned.

I have two TSam objects (derived from TPersistent) created and loaded into a

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 13:19

    A couple of things and I'm asking because I can't see your code.

    Given the following code:

    procedure TForm1.FormCreate(Sender: TObject);
    var
       wObjLst : TObjectList;
    begin
       wObjLst := TObjectList.Create;
       try
          wObjlst.OwnsObjects := true;
          wObjlst.Add(TPersistent.Create);
          wObjlst.Add(TPersistent.Create);
       finally
          freeandnil(wObjlst);
       end;
    end;
    

    This works with out error.

    You state that

    At runtime, a form creates a TStringGrid and then the AsmJob which creates those two SAM objects (and load some data from disk in each of them). The AsmJob is also assigned to the grid. When the form is destroyed, the Grid takes care of the AsmJob by freeing it, which frees the TSam objects. Here is the problem: the first object is freed withot problems but the second one dies when its inherited method (in Destroy destructor) is called.

    My first question is how does the AsmJob get assigned to TStringGrid so that the TStringGrid destroys the AsmJob, can you show us?

    Second, why create a descendant of TObjectList to get it to store two objects and then free free them instead of creating them yourself and letting the TObjectList destroy them as shown above.

    The other thing to try is to download the full FastMM4 package from fastmm.sourceforge.net, install it and use the fulldebug dll to trace out exactly what object is failing. You and I are assuming that it's one of the SAM objects and it might or might not be.

提交回复
热议问题