簡體   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