Page 1 of 1

MappingSource - static vs non-static member

Posted: Wed 05 Oct 2011 09:00
by dilbert
After updating our project to dotConnect for Mysql to version 6.5 and generating new model class we started to run to high cpu usage and memory-leak problems (on our website) right after a new build was deployed.

After some experiments we realized that the problem is not in new dotConnect version but in the generated class.
And the only change we found was that you replaced static member mappingSource by a (static) method which creates non-static instance of AttributeMappingSource. So for each new instance of data context a new instance of mapping source is created as well.

Is there any reason why mapping source is not static member by default?
And is it recommended to create own static instance of it and pass it to constructor of datacontext class?

Thanks in advance.

Posted: Fri 07 Oct 2011 13:51
by StanislavK
Thank you for your report, we plan to change this behaviour:
- for the models using MappingMode == 'Attribute', a static MappingSource object will be created and passed to the parameterless constructor of [YourDataContext];
- for the models with MappingMode == 'File', no static mapping source will be used by default.

Passing your own static mapping source to the constructor of your DataContext descendant should not cause any problems.

Posted: Thu 17 Nov 2011 08:39
by StanislavK
We've implemented these changes. They are available in the latest 3.0.14 build of LinqConnect. The new build can be downloaded from
http://www.devart.com/linqconnect/download.html
(the trial and free versions) or from Registered Users' Area (for users with active subscription only).

For the detailed information about the fixes and improvements available in LinqConnect 3.0.14, please refer to
http://www.devart.com/forums/viewtopic.php?t=22548