LicenseInitilizer memory leak on db connection?

238
0
05-05-2019 07:08 PM
by Anonymous User
Not applicable

LicenseInitializer leaks memory when call are made to a SQL server using LINQ.  

The code below leaks finalization handles, one for each data context created.  I believe that the esri licence system is listening for database connection events and firing an event handler.  I expect this is required to check licencing of SDE databases. The SQl server I am using does not have an SDE, it is a vanilla MS SQL server,  Evidently the fired event handler creates a number of objects that are not finalized/disposed correctly and accumulate in memory as they can't be garbage collected.  

Adding a "GC.WaitForPendingFinalizers();" in the for loop, after the DataContext has been destroyed seems to release the offending objects but this is computationally expensive.

I believe this is a bug in esri's licencing system.  Has anyone seen this previously.  

Thanks

Steven 

using ESRI.ArcGIS.esriSystem;

using System;

using System.Collections.Generic;

using System.Text;

 

using System.Data.Linq;

namespace ArcLeakTesting

{

    class Program

    {

        private static LicenseInitializer m_AOLicenseInitializer = new ArcLeakTesting.LicenseInitializer();

 

        [STAThread()]

        static void Main(string[] args)

        {

            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] {esriLicenseProductCode.esriLicenseProductCodeStandard , new esriLicenseExtensionCode[] { });

            for (int i = 0; i < 1000000; i++)

            {

                using (DataContext db = new DataContext(@"Server=tcp:XXXX\SQLEXPRESS,YYYYY;Database=ZZZZZ;User Id = AAAAAA;Password=BBBBBBB"))

                {

                }

            }

            m_AOLicenseInitializer.ShutdownApplication();

        }

    }

}

0 Kudos
0 Replies