繁体   English   中英

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

[英].Net Self Hosted WCF Windows Service Memory Leak

我收集了三个利用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日更新-我们最终在服务B和服务A中无法使用WCF接口,报告它无法向其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)

如评论中所述,消耗的400Mb不一定表示内存泄漏。 但是您可以使用内存探查器确保没有泄漏。 在您的情况下,我建议使用dotMemory,因为它可以连接到远程主机上的进程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM