Print Page | Close Window

Troubleshooting OutOfMemory Exceptions

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2591
Printed Date: 29-Jul-2026 at 8:35pm


Topic: Troubleshooting OutOfMemory Exceptions
Posted By: jipock
Subject: Troubleshooting OutOfMemory Exceptions
Date Posted: 29-Mar-2011 at 12:30pm
Good Afternoon,
 
I've got an application that some people are using fairly frequently, and I'm occasionally getting reports of "OutOfMemory" errors. They've been happening a couple times a day, MAX (and the app is used hundreds of times throughout the day). These are relatively new machines, and have plenty of memory. They reboot every evening. The errors occur in IdeaBlade.EntityModel.RemoteEntityServerProxyBase.CheckConnection() function and in a EntityQueryPagedCollectionView.LoadPageComplete() function. Since this is outside of my code, I was wondering whether or not anyone has seen this and/or knows good ways to troubleshoot. This is intermittent and not immediately reproducable.
 
Any thoughts?



Replies:
Posted By: DenisK
Date Posted: 30-Mar-2011 at 2:58pm
Hi jipock;

Could you provide the full stack trace of one of these errors?


Posted By: jipock
Date Posted: 31-Mar-2011 at 5:17am
Gladly. These are three of the errors... They happened about the same time (within a second or two). Since they looked slightly different, I wanted to include all of them.
 
I suppose the problem could be in my code, so any tips on troubleshooting / narrowing down the issue would be most appreciated.
 
 
 
 
Error: Exception of type 'System.OutOfMemoryException' was thrown.  Inner Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.     at IdeaBlade.EntityModel.RemoteEntityServerProxyBase.CheckConnection(Exception pException)     at IdeaBlade.EntityModel.EntityServerProxy.Fetch(SessionBundle bundle, IEntityQuerySurrogate query)     at IdeaBlade.EntityModel.EntityManager.AsyncFetchWorker(AsyncEventArgs state)  StackTrace:    at IdeaBlade.EntityModel.EntityQueriedEventArgs`1.get_Results()     at MyNamespace.ViewModels.OpenClassSearchViewModel.GetAllServicesQuery_Completed(EntityQueryOperation`1 args)     at IdeaBlade.EntityModel.BaseOperation`2.OnCompleted()     at IdeaBlade.EntityModel.BaseOperation`2.IdeaBlade.EntityModel.IHasAsyncEventArgs.OnCompleted()     at IdeaBlade.EntityModel.AsyncProcessor`1.<>c__DisplayClass2.<.ctor>b__0(TArgs args)     at IdeaBlade.EntityModel.AsyncProcessor`1.Signal()     at IdeaBlade.EntityModel.AsyncProcessor`1.<Execute>b__5(Object x) 
Error: There was an error loading your information. Please note the following:     Exception of type 'System.OutOfMemoryException' was thrown..   Please contact your administrator if this happens frequently.    .More Information:
Error: Exception of type 'System.OutOfMemoryException' was thrown.  Inner Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.     at IdeaBlade.EntityModel.RemoteEntityServerProxyBase.CheckConnection(Exception pException)     at IdeaBlade.EntityModel.EntityServerProxy.Fetch(SessionBundle bundle, IEntityQuerySurrogate query)     at IdeaBlade.EntityModel.EntityManager.AsyncFetchWorker(AsyncEventArgs state)  StackTrace:    at IdeaBlade.EntityModel.EntityQueriedEventArgs`1.get_Results()     at MyNamespace.ViewModels.OpenClassSearchViewModel.GetAllServicesQuery_Completed(EntityQueryOperation`1 args)     at IdeaBlade.EntityModel.BaseOperation`2.OnCompleted()     at IdeaBlade.EntityModel.BaseOperation`2.IdeaBlade.EntityModel.IHasAsyncEventArgs.OnCompleted()     at IdeaBlade.EntityModel.AsyncProcessor`1.<>c__DisplayClass2.<.ctor>b__0(TArgs args)     at IdeaBlade.EntityModel.AsyncProcessor`1.Signal()     at IdeaBlade.EntityModel.AsyncProcessor`1.<Execute>b__5(Object x)
 
 
Error: Exception of type 'System.OutOfMemoryException' was thrown.  Inner Exception:   StackTrace:    at System.ServiceModel.Channels.BufferManager.GCBufferManager.TakeBuffer(Int32 bufferSize)     at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()     at System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult..ctor(HttpInput httpInput, AsyncCallback callback, Object state)     at System.ServiceModel.Channels.HttpInput.BeginParseIncomingMessage(AsyncCallback callback, Object state)     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.ProcessResponse(HttpWebResponse response, WebException responseException)     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.OnGetResponse(IAsyncResult result)     at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)     at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)     at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()     at System.Threading.ThreadPoolWorkQueue.Dispatch()     at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() 
Error: Exception of type 'System.OutOfMemoryException' was thrown.  Inner Exception:   StackTrace:    at System.IO.MemoryStream.set_Capacity(Int32 value)     at System.IO.MemoryStream.EnsureCapacity(Int32 value)     at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)     at MS.Internal.InternalWebRequestStream.Write(Byte[] buffer, Int32 offset, Int32 count)     at System.ServiceModel.Channels.BytesReadPositionStream.Write(Byte[] buffer, Int32 offset, Int32 count)     at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.WebRequestOutputStream.Write(Byte[] buffer, Int32 offset, Int32 count)     at System.ServiceModel.Channels.HttpOutput.SendAsyncResult.WriteMessage(Boolean isStillSynchronous)     at System.ServiceModel.Channels.HttpOutput.SendAsyncResult.OnGetOutputStream(IAsyncResult result)     at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)     at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult.OnGetRequestStream(IAsyncResult result)     at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass9.<InvokeGetRequestStreamCallback>b__7(Object state2)     at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)     at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()     at System.Threading.ThreadPoolWorkQueue.Dispatch()     at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
 


Posted By: DenisK
Date Posted: 31-Mar-2011 at 12:25pm
Hi jipock;

From your stack trace, it looks like you're getting the out of memory exception after a query. You might want to check if you're fetching too large of data sets into the memory.

FYI, Microsoft's guideline on this may prove useful.

http://msdn.microsoft.com/en-us/library/9w766t6y%28v=VS.100%29.aspx - http://msdn.microsoft.com/en-us/library/9w766t6y(v=VS.100).aspx


Posted By: jipock
Date Posted: 05-Apr-2011 at 5:24am
Thanks for getting back to me (I didn't see your post until now...).
 
There are a few things about this:
 
1) Judging by when they're getting the errors, the record sets aren't terribly large (at most, the recordsets are hundreds of rows, approximately 20 columns of non-MAX types).
 
2) If it were purely a data-driven error, then the error should be fairly easy to reproduce. This is not.
 
3) The Server-side of this application is shared with other applications, some of which can be memory-intensive. Perhaps this might be causing a problem.
 
 
Plan:
   Start logging the queries, in addition to the errors... This should validate/ reject issue #1.
   Consider moving the Server to a different machine (if possible).
 
Any other thoughts / suggestions / troubleshooting advice?
 


Posted By: DenisK
Date Posted: 05-Apr-2011 at 11:11am
Hi jipock;

I'm wondering if the debug log can also provide us with some clues. Would you be able to upload one that was created during one of the application runs that throws the exception?


Posted By: jipock
Date Posted: 05-Apr-2011 at 11:29am
The next time this happens, I'll see if I can grab the debug log. Again - it is a regular, but inconsistent problem.
One other thing of note - the last time this happened, the server didn't show any signs of running out of memory (it was 60% utilized according to task manager). I'm leaning more against a resource issue on the server (but haven't ruled it out).
 
Thanks again for your time.
 
 


Posted By: DenisK
Date Posted: 05-Apr-2011 at 12:08pm
No problem jipock. I wish I could help more. I'll be waiting for that debug log.

It also occurs to me that this maybe has something to do with the accumulation of memory usage over a period of time since you said that it is regular but inconsistent. Quoting from Microsoft's site, this could be the reasons:

- Creating excessive cache entries (over a period of time)
- Too much data in session state or too many sessions. (over a period of time)

Hope this helps.


Posted By: jipock
Date Posted: 14-Apr-2011 at 5:20am
Thanks, Denis.
 
A client just recieved the error again, grabbed the debug log, I looked though the DebugLog.xml and there is no sign of any errors regarding the Out Of Memory issue.
 
Is there anything I can do for more verbose logging? Or, perhaps, the error is purely in the client assembly? Client side errors wouldn't log in the Server log, right?
 
Let me know if you'd like the log and how to get it to you. (~ 3.5 mb).
 


Posted By: DenisK
Date Posted: 14-Apr-2011 at 11:01am
Hi jipock;

Could you upload the debug log through the customer support web form and just reference this forum post?

That's correct. Client side errors wouldn't log in the server log. Is it possible to get the client's log as well?


Posted By: jipock
Date Posted: 18-Apr-2011 at 7:20am
This is a Silverlight client being run. How is the best way of getting the client log off the system? I can only assume this is stored in isolated storage.
-J


Posted By: jipock
Date Posted: 18-Apr-2011 at 7:26am
Also - Log File is uploaded.


Posted By: DenisK
Date Posted: 18-Apr-2011 at 11:35am
Hi jipock;

I've received the debug log. Thanks. You're right, I don't see anything obvious that would indicate clues to the cause for the out of memory exceptions.

As for your question on how to get the client log, since writing to the file systems is not supported in Silverlight client (as well as Azure), you have to implement your own custom logging. Please see the following DRC page on how to do that. The custom logger is also useful if you want to do more verbose logging.

http://drc.ideablade.com/xwiki/bin/view/Documentation/log - http://drc.ideablade.com/xwiki/bin/view/Documentation/log



Print Page | Close Window