This project is read-only.
1
Vote

Getting OutOfMemoryException while waiting for connection

description

Hi

I am trying to build WebServer to show list of isolatedstorage files and download them on user's computer. apparently its working quite fine but some times I get following exception which crashes the app, while waiting on connections. Is it possible that its my code which supposed to close socket connection. by the way I have compared my code with your sample, it seems same to me. can you please give me some clue on this?
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at HttpServer.WebServer.getData(Socket sock)
   at HttpServer.WebServer.handler(Object o)
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)

comments

GoodDayToDie wrote Aug 10, 2014 at 6:17 AM

Well, the current version of the app uses 1MB buffers for request handling, but older versions opened the whole request at once and that could easily have caused out-of-memory on large requests. If you were just waiting on a connection (i.e. there wasn't an actual request coming in) the code shouldn't have gotten to the getData() function... Also, I wouldn't expect that to have anything to do with closing the socket.

Could you try the latest version and see if the problem still occurs? Thanks!