Freigeben über


There's a fix now available for memory issues with repeated CDOEX/ExOLEDB datasource.open calls

This was a straight forward issue that I worked on a short period of time ago and thought that it was worthy of posting the results.

The issue that we were encountering was with a service application that a customer had written that was doing a lot of repeated calls to some Exchange mailboxes using CDOEX.  Over time, as any good leaky application will, the memory being used by this application began to grow and grow.   I bring this issue up since it could be something that you might encounter, since it doesn't take much to expose the problem.  It just so happens that this can occur with some really simple CDOEX code.   For this problem to occur you really only need to be using code similar to the following:

Dim Conn As ADODB.Connection
Dim objAppt As CDO.Appointment
Dim i As Long
   
For i = 1 To 50000
     Set objAppt = New CDO.Appointment
     Set Conn = New ADODB.Connection
     Conn.Provider = "exoledb.datasource"
     Conn.Open "https://ExchangeServer/Exchange/user/Calendar", "", "", 0
        
     objAppt.DataSource.Open "https://ExchangeServer/Exchange/user/Calendar/item.eml", Conn, ADODB.ConnectModeEnum.adModeReadWrite,  ADODB.RecordCreateOptionsEnum.adFailIfNotExists, ADODB.RecordOpenOptionsEnum.adOpenSource, "", ""
       
      ' Do other logic here...

      'Clean up
      Conn.Close
      Set objAppt = Nothing
      Set Conn = Nothing
Next

After some amount of time of researching this with various tools including UMDH, it turned out that this problem was an issue with the ADO components that CDOEX and ExOLEDB uses to access the Exchange store.  And to resolve this issue all you just need to do is make sure that you are running at least this version of msado15.dll (2.82.3959.0), which luckily is now available publicly in Windows 2003 SP2. 

So if you are seeing anything like this I suggest that you go ahead and give Windows 2003 SP2 a try.