I've been troublshooting some Application Log issues for a client today, and found multiple instances of Commerce Server error 4116, which all message that goes something like this:
The Commerce Server runtime has detected that more than # instances of the SiteConfigReadOnlyFreeThreaded object have been created. Creating many SiteConfigReadOnlyFreeThreaded instances will negatively affect the performance of the site. Please refer to the Commerce Server documentation for the recommended use of the SiteConfigReadOnlyFreeThreaded object.
After a quick google search for "SiteConfigReadOnlyFree", I came across Tom Shultz's Blog which clearly identified that the warnings were coming from one of two places:
- Your site is configured to use the CommerceDataWarehouseAuthenticationModule (in which case, this problem was resolved in SP1, so it really shouldn't be this problem, seeing how SP2 has been out for a long time now)
- You're creating new instances of Commerce System Context objects, each of which create new SiteConfigReadOnlyFree in memory. This happened to be the case for us.
The correct practice here is to only use the CommerceContext.Current object (as opposed to creating new ones each time), and this will avoid creating new SiteConfigReadOnlyFree objects over and over in memory.