Memory error preparing a report

I'm a new user to Fastreport 4 but still encountering a strange problem:

I've created a designtime TfrxReport with a design containing expressions explicit references like [frxDBDataset."CompanyID"] in the memofields
The actual dataset, resulting from a sql query and stored in a kbMemTable, is added to the report at runtime by assigning the kbmTable to the frxDBDataset.dataset property.

When i try to run report.prepare, an error is reported by FastMM ( see details below).
It looks like TfsXMLItem is freeing memory that is allocated by TDatasaet.GetFieldData [img]style_emoticons/<#EMO_DIR#>/dry.gif" style="vertical-align:middle" emoid="<_<" border="0" alt="dry.gif" /> What is going wrong here, and how can i correct it or work around it? The generation of the data and report is done in one subthread[/img]
  //
  // Generating data and storing in kbmData
  // ...

  frxDBDataset.Dataset := kbmData;
  frxDBDataset.Open;
  with aReport.EngineOptions do
  begin
    NewSilentMode := simReThrow;
    UseGlobalDataSetList := False;
  end;

  with aReport do
  begin
    EnabledDataSets.Add(frxDBDataset);
    PrepareReport(false)
  end;




FASTMM: memory manager eventlog:
--------------------------------2016/2/23 13:55:54--------------------------------
FastMM has detected an error during a FreeMem operation. The block footer has been corrupted. 

The block size is: 30

This block was allocated by thread 0xAB0, and the stack trace (return addresses) at the time was:
406C15 
40E58D 
40E6BE 
6C8890 [Data.DB.pas][Data][Data.DB.TDataSet.GetFieldData][12552]
6B6417 [Data.DB.pas][Data][Data.DB.TField.GetData][4779]
40E6BE 
6B8B26 [Data.DB.pas][Data][Data.DB.TWideStringField.GetValue][5867]
6B89EB [Data.DB.pas][Data][Data.DB.TWideStringField.GetAsVariant][5845]
1063495 [frxDBSet.pas][frxDBSet][frxDBSet.TfrxDBDataset.GetValue][354]
105E5AD [frxClass.pas][frxClass][frxClass.TfrxReport.DoGetValue][9304]
105CD5F [frxClass.pas][frxClass][frxClass.TfrxReport.Calc][8749]

The block was previously used for an object of class: TfsXMLItem

The block is currently used for an object of class: Unknown

The allocation number is: 2038485

The block was previously freed by thread 0xAB0, and the stack trace (return addresses) at the time was:
406BC2 
409F01 
40A645 
FBB523 [fs_xml.pas][fs_xml][fs_xml.TfsXMLItem.Destroy][240]
409FFF 
FBB54C [fs_xml.pas][fs_xml][fs_xml.TfsXMLItem.Clear][247]
FBB4ED [fs_xml.pas][fs_xml][fs_xml.TfsXMLItem.Destroy][236]
409FFF 
FBB54C [fs_xml.pas][fs_xml][fs_xml.TfsXMLItem.Clear][247]
FBB4ED [fs_xml.pas][fs_xml][fs_xml.TfsXMLItem.Destroy][236]
409FFF 

The current thread ID is 0xAB0, and the stack trace (return addresses) leading to this error is:
406BC2 
40E812 
40DB02 
6C893C [Data.DB.pas][Data][Data.DB.TDataSet.GetFieldData][12559]
6B6417 [Data.DB.pas][Data][Data.DB.TField.GetData][4779]
40E6BE 
6B8B26 [Data.DB.pas][Data][Data.DB.TWideStringField.GetValue][5867]
6B89EB [Data.DB.pas][Data][Data.DB.TWideStringField.GetAsVariant][5845]
1063495 [frxDBSet.pas][frxDBSet][frxDBSet.TfrxDBDataset.GetValue][354]
105E5AD [frxClass.pas][frxClass][frxClass.TfrxReport.DoGetValue][9304]
105CD5F [frxClass.pas][frxClass][frxClass.TfrxReport.Calc][8749]

Current memory dump of 256 bytes starting at pointer address 779B63A0:
00 00 00 00 16 00 00 00 43 00 48 00 4E 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 73 1C
D5 7A 80 80 80 80 80 80 00 00 00 00 81 64 9B 77 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
4E 93 1E 00 A6 6B 40 00 DF BC 40 00 10 BF 40 00 22 C3 FB 00 CB C3 FB 00 D9 9F 40 00 A2 C4 FB 00
A2 C4 FB 00 A2 C4 FB 00 A2 C4 FB 00 5C C5 FB 00 B0 0A 00 00 B0 0A 00 00 C2 6B 40 00 99 BD 40 00
99 DA 40 00 E1 D9 40 00 6F A0 40 00 FA 9E 40 00 45 A6 40 00 23 B5 FB 00 FF 9F 40 00 4C B5 FB 00
ED B4 FB 00 22 00 00 00 B0 04 02 00 6D 7A 99 84 8C 72 58 02 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 92 85 66 7B 80 80 80 80 00 00 61 60 9B 77
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 93 1E 00 A6 6B 40 00 DF BC 40 00 10 BF 40 00
.  .  .  .  .  .  .  .  C  .  H  .  N  .  L  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  s  .
??  z  ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â .  .  .  .  ??  d  ???  w  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
N  ???  .  .  ?¦Â Â k  @  .  ??  ??  @  .  .  ??  @  .  "  ??  ?»Â Â .  ??  ??  ?»Â Â .  ??  ??  @  .  ??  ??  ?»Â Â .
??  ??  ?»Â Â .  ??  ??  ?»Â Â .  ??  ??  ?»Â Â .  \  ??  ?»Â Â .  ?°Â Â .  .  .  ?°Â Â .  .  .  ??  k  @  .  ???  ??  @  .
???  ??  @  .  ??  ??  @  .  o  ? Â Â @  .  ??  ??  @  .  E  ?¦Â Â @  .  #  ?µÂ Â ?»Â Â .  ??  ??  @  .  L  ?µÂ Â ?»Â Â .
?­Â Â ??  ?»Â Â .  "  .  .  .  ?°Â Â .  .  .  m  z  ???  ???  ??  r  X  .  ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬
??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â ???  ??¦Â Â f  {  ??¬Â Â ??¬Â Â ??¬Â Â ??¬Â Â .  .  a  `  ???  w
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  O  ???  .  .  ?¦Â Â k  @  .  ??  ??  @  .  .  ??  @  .

Comments

  • edited 6:50PM
    Solved it!
    Turned out to be a problem with the kbmMemTable which caused an AV when reading a TWidestring field
    Replaced it with a TdxMemData from DevExpress and all problems were gone

Leave a Comment