EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FastMM4 detects 2 memory leaks in ecSyntMemo.pas

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
tranglos



Joined: 12 Dec 2007
Posts: 12
Location: Poland

PostPosted: Sat Jan 12, 2008 7:16 pm    Post subject: FastMM4 detects 2 memory leaks in ecSyntMemo.pas Reply with quote

Using Delphi 6.02 and the latest release of TSyntaxMemo, version 2.40, file dated 2007-12-01:

1. Create a new, empty application.

2. Put FastMM4 as the first unit used in the project file.

In FastMM4Options.inc enable the "FullDebugMode" define.
The library FastMM_FullDebugMode.dll, distruibuted with FastMM4, needs to be available for loading.

3. Include ecSyntMemo in the uses clause of the main form unit.

4. Run the application.

FastMM4 will report several memory leaks, some of which are "native" to Delphi6. The two remaining leaks appear only when ecSyntMemo.pas is included. (No need to drop the editor on the form, just include the unit).

The leaked resources are:
TLabel x 1,
TList x 1


Is this a known issue, please?

On edit: Since just the unit inclusion triggers the leak, I investigated which specific unit was responsible. For the leak to occur it's enough to include ecSyntGramma (instead of ecSyntaxMemo). Including any unit that uses it, such as ecSyntAnal.pas, likewise causes the leak. In fact, many units trigger this problem, but since they often use each other in interface or implementation, it's difficult for me to find the one ultimately responsible without fully understanding how the unit hierarchy is arranged.

Thank you,
marek
Back to top
View user's profile Send private message Visit poster's website
tranglos



Joined: 12 Dec 2007
Posts: 12
Location: Poland

PostPosted: Sat Jan 12, 2008 7:51 pm    Post subject: I think I've found the source Reply with quote

After a few more checks, I think the place where the leaks occur is ecPopupCtrl.pas.

In the Initialization block the RegisterPopupControlClass is called, but the TList assigned there is apparently never released.

It seems to account only for the TList, not the TLabel leak. However, freeing the PopupControlClasses instance in the Finalization block eliminates both leaks, including the TLabel:

Code:
Finalization
  FreeAndNil( PopupControlClasses );


After that no more leaks are reported. I don't understand why this eliminates the TLabel leak as well, since PopupControlClasses only holds a reference to the class, not an instance of TLabel.
Back to top
View user's profile Send private message Visit poster's website
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Sun Jan 13, 2008 3:33 pm    Post subject: Reply with quote

Yes, memory leak is fixed.
Thank you.

Quote:
After that no more leaks are reported. I don't understand why this eliminates the TLabel leak as well, since PopupControlClasses only holds a reference to the class, not an instance of TLabel.


I think Fast MM incorrectly associated allocation of data buffer of TList with TLabel class, because allocation occured when adding first member which if of TLable class type.

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group