结束调用中由于异常导致的内存泄漏

时间:2012-11-04 11:49:05

标签: .net remoting

我正在使用.Net Remoting在两台服务器之间发送对象。 在我使用EndInvoke的情况下,根据需要通过“Begin Invoke”机制发送对象,但在结束调用期间始终抛出以下异常:

System.Net.WebExceptionSystem.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond …
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
   at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.AsyncHttpClientRequestState.ProcessGetRequestStreamCompletion(IAsyncResult iar)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Core.Common.CLSAPI.EventArrivedHandler.EndInvoke(IAsyncResult result)

几个小时后,我的应用程序由于“Out of Memory Exception”而崩溃,并且从转储文件中我可以看到我尝试发送的所有对象仍然被其中一个远程处理对象引用,因此仍然没有被GC收集。 在EndInvoke中处理异常以避免内存泄漏的正确方法是什么?

我知道这个问题可能是由客户端的某些更改引起/修复的,但是我必须了解我可以在服务器端进行哪些更改以确保服务器的健壮性。

0 个答案:

没有答案