Intermittent System.OutOfMemoryException with ADODB.RecordSet.Open

I

Iain Porter

I am using ADO to read mailbox contents in Exchange 2000.
Every so often (about 10 errors a day out of 20,000 or more requests)
calls to RecordSet.Open will generate an OutOfMemoryException:
"System.OutOfMemoryException: Not enough storage is available to
complete this operation".
I am able to replicate this behaviour by setting up 2 logins and then
beating on them both until one breaks, usually after about 5 or 6
attempts.
I am trying to get past this problem to buy more time before moving
the application over to using ADO.NET.
Any ideas....?
 
A

ashelley

I am using ADO to read mailbox contents in Exchange 2000.
Every so often (about 10 errors a day out of 20,000 or more requests)
calls to RecordSet.Open will generate an OutOfMemoryException:
"System.OutOfMemoryException: Not enough storage is available to
complete this operation".
I am able to replicate this behaviour by setting up 2 logins and then
beating on them both until one breaks, usually after about 5 or 6
attempts.
I am trying to get past this problem to buy more time before moving
the application over to using ADO.NET.
Any ideas....?

The only thing I can think of is buying more ram. Your application
sounds like it could benefit from a object pool and some load
limitting. Are you explicitly destroying the objects? If you are
storing them in sessions you could try lowering the session time out
so sessions clean up faster but by the sounds of it you are running
out of memory real quickly. I think the best thing to do would be to
upgrade the hardware to handle the load u're trying to pull.

-Adam
 
K

Kondratyev Denis

Imho upgrade of hardware is best idea too :) You can use profiler and
perfonace counters for localize problem.
Also you can use cache of results (by add CacheDuration=[seconds] in
WebMethod attribute) or cache of data (before search in DB your chech data
in cache by Context.Cache[mailboxId] and store all new data in cache). Many
information about caching in "Caching Architecture Guide for .NET Framework
Application" from Microsoft patterns and practices
(http://www.microsoft.com/resources/practices/completelist.asp).
 
I

Iain Porter

We have nearly 2 Gigs of RAM on that machine and the problem can be
replicated when there is little traffic. It almost seems to be a
threading issue as the OutOfMemoryException only occurs when 2
requests are made simultaneously. One request will be processed fine
while the other will generate an exception. Hundreds of other requests
will be processed correctly and then another exception will be thrown.
From the logs it is clear that this is only happening when one or more
requests happen to be made simultaneously.
 
K

Kondratyev Denis

Do u localize lines of code where exception throwed? Whether there can be a
reason of exception in mistakes of synchronization? Can u try use critical
section or so in this web method?
 
I

Iain Porter

Here is a typical method that will throw an exception (written in c#)

private FolderContent DoGetContents(string query, string url, string
rootURL, int page, int pageSize) {
ADODB.Connection conn = new ADODB.ConnectionClass();
conn.Provider = "EXOLEDB.DataSource";
ADODB.Recordset recordset = new ADODB.Recordset();
try {
// Open the folder connection.
conn.Open(url, "", "", 0);
recordset.Open(query, conn, CursorTypeEnum.adOpenForwardOnly,
LockTypeEnum.adLockReadOnly, 0);
.......rest of method .........
} catch (Exception ex) {
string msg = "Could not get folder contents ";
throw new SoapException(msg, SoapException.ServerFaultCode,
Context.Request.Url.AbsolutePath, null, ex); } finally {
if (recordset.State != (int)ObjectStateEnum.adStateClosed)
recordset.Close();
if (conn.State != (int)ObjectStateEnum.adStateClosed)
conn.Close();
}
}

The call to recordset.Open throws the OutOfMemoryException.
One other point is that if I execute two requests almost
simultaneously it is the first request that will throw the exception
and not, as you would expect, the second.
 
K

Kondratyev Denis

Is your system have enought memory in this moments? Try rewrite this
function with ADO.NET and DataReader and check exception. I dont work with
ADO from C# code but can think that is library bug or so.
 
I

Iain Porter

The problem is now becoming clearer though no more solveable.
It seems that the symptoms were masking the real problems. Each day we
have been getting more exceptions until finally this afternoon it
became critical and every request generated an OutOfMemoryException.
At this point we had to reboot the Exchange server. Now it is
performing great and I cannot generate an exception whereas before I
could do it easily.
Looking back through the logs for the last 4 weeks which is when the
server was last rebooted I see that the Exceptions did not start
getting thrown until after 10 days, after which point they steadily
increased in frequency until todays fiasco. The load has not changed
at all within that time frame which leads me to conclude that there is
a memory leak somewhere.
We are using the latest release of the DotNet Framework. (v1.1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top