.Net自托管WCF Windows服务内存泄漏

时间:2014-05-07 08:56:11

标签: .net wcf windows-services

我有三个使用WCF进行通信的.Net 4.0 Windows服务的集合。 请参阅以下服务的简化通信架构。

服务A从第三方关闭数据,然后通过WCF与服务B通信。这是通过命名管道绑定与InstanceContextMode和ConcurrencyMode的默认设置。

然后,服务B将此数据推送到服务C的集合中。这又是通过命名管道绑定与InstanceContextMode和ConcurrencyMode的默认设置。

服务B内发生内存泄漏。启动时,该服务消耗大约30MB,但几小时后,这会增加到超过400MB。

内置的VS2013分析工具表明,服务B中的WCF端点方法类型占用了很大比例的托管内存大小,但这是应用程序以80MB运行而不是我们看到的400MB。似乎没有任何选项可以将内存探查器从visual studio连接到远程服务器。

任何有关追踪内存泄漏原因的建议和/或识别未关闭的恶意WCF连接的提示都将非常感激。

- 2014年8月5日更新 - 我们最终WCF接口在服务B和服务A中变得不可用,报告它无法向其WCF接口发送消息。申请A报告的例外情况详述如下:

08/05/2014 01:59:49,ApplicationA,Other,Critical,An error occurred in Service|mWCFClientManager. System.ServiceModel.CommunicationException: There was an error writing to the pipe: Unrecognized error 232 (0xe8). ---> System.IO.PipeException: There was an error writing to the pipe: Unrecognized error 232 (0xe8).
   at System.ServiceModel.Channels.PipeConnection.StartSyncWrite(Byte[] buffer, Int32 offset, Int32 size, Object& holder)
   at System.ServiceModel.Channels.PipeConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Channels.PipeConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
   at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)
   at System.ServiceModel.Channels.BufferedConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
   at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

1 个答案:

答案 0 :(得分:0)

如评论中所述,消耗400Mb并不一定表示内存泄漏。但是您可以使用内存分析器确保没有泄漏。在您的情况下,由于dotMemory,我建议it allows attaching to processes on a remote host