SRichViewEdit & FastMM4

General TRichView support forum. Please post your questions here
Post Reply
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

SRichViewEdit & FastMM4

Post by vit »

Hi!

I try to implement some application using SRichViewEdit but FastMM4 has detected memory using troubles.

In general application represents form with TPageControls and two buttons - "Add" and "Delete". When user push "Add" button the new page with TMyFrame is added to TPageControl. "Delete" button delete active page (with destroying TMyFrame).

TMyFrame - is frame I make for error demonstration purposes. I just open a form Demos\ActionTest\Unit3.pas (from srv_demos.zip), select and copy all components from this form, and then paste its in TMyFrame. Besides, I add dmActionsSRV.pas (from same demo project) to my project.

So, user can add and delete pages with cool text editors.

But FastMM4 (in FullDebugMode) detects memory error! To reproduce this error is needed to push "add" twice, then "delete" then "add" again.

I have prepare test project you can download its from
http://webfiles.ru/control/?file_id=191 ... 89c06149b8

Besides you can download my FastMM4Options.inc from here http://webfiles.ru/control/?file_id=191 ... a939e4d11e

It looks like error not appear if delete SclRVRuler1 from TMyFrame.

Any suggestions?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What version of ScaleRichView do you use?

(in some old versions, errors with a ruler were possible after linking it to another editor/unlinking, because references were not updated properly)
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

I have update ScaleRichView to v3.5, RichViewEdit - to 12.5.2 and RV Actions to 2.2.2 and the error still appear.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, we cannot reproduce it. We tried in D5,6,7,2007, no crashes.

May be your application is still compiled with old files? Did you delete old versions when installing new versions of controls?
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Sergey Tkachenko wrote:Sorry, we cannot reproduce it. We tried in D5,6,7,2007, no crashes.

May be your application is still compiled with old files? Did you delete old versions when installing new versions of controls?
Yes, I have delete all files of old versions.

I click several times to add/del buttons and once when I click "add" FastMM throws message:

Code: Select all

---------------------------
Project1.exe: Memory Error Detected
---------------------------
FastMM has detected an error during a GetMem operation. FastMM detected that a block has been modified after being freed. 



Modified byte offsets (and lengths): 14(1)



The previous block size was: 108



This block was previously allocated by thread 0xF34, and the stack trace (return addresses) at the time was:

402A23 [System][@GetMem]

403B23 [System][TObject.NewInstance]

403EFE [System][@ClassCreate]

53922E [RVThread.pas][RVThread][TRVWordEnumThread.Create][101]

52EEE0 [RichView.pas][RichView][TCustomRichView.StartLiveSpelling][3637]

4F265E [RVEdit.pas][RVEdit][TCustomRichViewEdit.DoChange][2626]

4F2682 [RVEdit.pas][RVEdit][TCustomRichViewEdit.Change][2636]

69C68D [RVRuler.pas][RVRuler][TRVRuler.DoMarginChanged][374]

6A0B21 [SclRVRuler.pas][SclRVRuler][TSclRVRuler.DoMarginChanged][707]

5B268F86 [Unknown function at IsThemeActive]

403D81 [System][@CallDynaInst]

6979C7 [Ruler.pas][Ruler][TCustomRuler.SetRightMargin][5660]

69DAA6 [RVRuler.pas][RVRuler][TRVRuler.UpdateRulerMargins][819]

69D331 [RVRuler.pas][RVRuler][TRVRuler.RichViewEditResize][651]

69D358 [RVRuler.pas][RVRuler][TRVRuler.RichViewEditResize][654]

5A26DB [RVScroll.pas][RVScroll][TRVScroller.DoAfterResize][797]

5A1C16 [RVScroll.pas][RVScroll][TRVScroller.UpdateScrollBars][525]

53B94B [RVRVData.pas][RVRVData][TRichViewRVData.SetDocumentAreaSize][877]

545213 [CRVFData.pas][CRVFData][TCustomRVFormattedData.Format_][3291]

545391 [CRVFData.pas][CRVFData][TCustomRVFormattedData.Format_][3327]

676428 [SclRView.pas][SclRView][TSRichViewEdit.GetClientRect][11672]

69E029 [RVRuler.pas][RVRuler][TRVRuler.UpdateTableEditor][967]

6A0D00 [SclRVRuler.pas][SclRVRuler][TSclRVRuler.DoMarginChanged][739]

5B27E615 [Unknown function at DrawThemeEdge]

403D81 [System][@CallDynaInst]

4E1E30 [RVERVData.pas][RVERVData][TRVEditRVData.Format_][4790]

46A448 [Controls.pas][Controls][TControl.GetClientHeight][3491]



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



The allocation number was: 82460



The block was previously freed by thread 0x474, and the stack trace (return addresses) at the time was:

402A43 [System][@FreeMem]

403B41 [System][TObject.FreeInstance]

403F49 [System][@ClassDestroy]

53929D [RVThread.pas][RVThread][TRVWordEnumThread.Destroy][111]

403B87 [System][TObject.Free]

427579 [Classes][ThreadProc]

408FC8 [FastMM4.pas][FastMM4][FastFreeMem][4566]

404946 [System][ThreadWrapper]

7C80B713 [Unknown function at GetModuleFileNameA]

408FC8 [FastMM4.pas][FastMM4][FastFreeMem][4566]



The current thread ID is 0xF34, and the stack trace (return addresses) leading to this error is:

40A589 [FastMM4.pas][FastMM4][DebugGetMem][6775]

402A23 [System][@GetMem]

403B23 [System][TObject.NewInstance]

403EFE [System][@ClassCreate]

403B58 [System][TObject.Create]

433779 [Graphics.pas][Graphics][TBitmap.NewImage][5782]

433790 [Graphics.pas][Graphics][TBitmap.NewImage][5784]

4336BA [Graphics.pas][Graphics][TBitmap.NewImage][5764]

432975 [Graphics.pas][Graphics][TBitmap.CopyImage][5333]

434430 [Graphics.pas][Graphics][TBitmap.SetPixelFormat][6211]

68D7E0 [Ruler.pas][Ruler][TCustomRuler.Create][2158]

69BFF4 [RVRuler.pas][RVRuler][TRVRuler.Create][198]

69EF20 [SclRVRuler.pas][SclRVRuler][TSclRVRuler.Create][102]

42337C [Classes][CreateComponent]

4235AA [Classes][TReader.ReadComponent]

422D4E [Classes][TReader.EndOfList]

4237F6 [Classes][TReader.ReadDataInner]

423764 [Classes][TReader.ReadData]

427E46 [Classes][TComponent.ReadState]

469BD6 [Controls.pas][Controls][TControl.ReadState][3273]

46E3C1 [Controls.pas][Controls][TWinControl.ReadState][5381]

423615 [Classes][TReader.ReadComponent]

422D4E [Classes][TReader.EndOfList]

4237F6 [Classes][TReader.ReadDataInner]

423764 [Classes][TReader.ReadData]

427E46 [Classes][TComponent.ReadState]

469BD6 [Controls.pas][Controls][TControl.ReadState][3273]



Current memory dump of 256 bytes starting at pointer address 7FF7A6A0:

3C CD 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 00 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00

3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00

3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 3C D0 6C 00

3C D0 6C 00 3C D0 6C 00 3C D0 6C 00 D0 84 0A 42 3C D0 6C 00 3C D0 6C 00 00 00 00 00 A1 4B F7 7F

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D9 9C 00 00 23 2A 40 00 23 3B 40 00 FE 3E 40 00

46 C2 42 00 88 56 47 00 60 16 5A 00 EA 5B 68 00 0D A6 40 00 3A A6 40 00 7C 33 42 00 AA 35 42 00

4E 2D 42 00 F6 37 42 00 35 37 42 00 46 7E 42 00 D6 9B 46 00 C1 E3 46 00 24 45 42 00 6B 1E 42 00

08 EC 41 00 92 ED 41 00 FF 4B 44 00 A6 C7 46 00 52 5E 7F 00 75 2C 38 7E 52 5E 7F 00 FB 95 40 00

<  Í  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  .  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .

<  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .

<  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .  <  Ð  l  .

<  Ð  l  .  <  Ð  l  .  <  Ð  l  .  Ð  „  .  B  <  Ð  l  .  <  Ð  l  .  .  .  .  .  ¡  K  ÷  

.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Ù  œ  .  .  #  *  @  .  #  ;  @  .  þ  >  @  .

F  Â  B  .  ˆ  V  G  .  `  .  Z  .  ê  [  h  .  .  ¦  @  .  :  ¦  @  .  |  3  B  .  ª  5  B  .

N  -  B  .  ö  7  B  .  5  7  B  .  F  ~  B  .  Ö  ›  F  .  Á  ã  F  .  $  E  B  .  k  .  B  .

.  ì  A  .  ’  í  A  .  ÿ  K  D  .  ¦  Ç  F  .  R  ^    .  u  ,  8  ~  R  ^    .  û  •  @  .


---------------------------
ÎÊ   
---------------------------
and IDE throws after:

Code: Select all

---------------------------
Debugger Exception Notification
---------------------------
Project SRVEMemoryCrash.exe raised exception class EOutOfMemory with message 'Out of memory'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------
In some cases is not enough to click twice "add" and then "del". Please try to make several clicks randomly.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I still cannot reproduce this problem.

Try the following change:

In RVThread.pas: delete the line

Code: Select all

FreeOnTerminate := True; 
In RichView.pas, in procedure TCustomRichView.ClearLiveSpellingResults, add

Code: Select all

    FWordEnumThread.Free; 
after

Code: Select all

    FWordEnumThread.Finish; 
Try these changes and inform me if they fixed the problem.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

no, this is not helps. But it seems like exception only raised in my machine and under my virtual PC image. So it is not critical since we use FastMM only for debug purposes.

P.S. we always use explicit thread destroying as you say in last post. Becouse it helps to fix errors in spell checking.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please do one more test.
With this FreeOnTerminate := True in RVThread.pas, change in RichView.pas:

Code: Select all

procedure TCustomRichView.ClearLiveSpellingResults;
var Thread: TRVWordEnumThread;
begin
  if FWordEnumThread<>nil then begin
    FWordEnumThread.Finish;
    Thread := FWordEnumThread;
    FWordEnumThread := nil;
    Thread.Free;
    DoClearLiveSpellingResults;
    FullInvalidate;
  end;
end;
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

No, this works worse.

I need note that test application wich I sent you is not pretty correspond to my application wich I develop. SRVEMemoryCrash start work fine when I updated components and changed code as you said first. But my main application still generating exception.

And when I change code as you said in last post SRVEMemoryCrash starts throw exception again (main application has no visible changes).
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

So, now I do not have a solution for this problem.
Since all is ok when working without FastMM debugging, I do not consider it as a critical problem.
Post Reply