据我所知,我有一台服务器在请求期间传输数据时抛出System.OutOfMemoryException。从这个轨迹来看,我的假设是对的吗?

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
  at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
  at System.Net.Security.NegotiateStream.AuthenticateAsServer(NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
  at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeAcceptor.OnAcceptUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)
  at System.ServiceModel.Channels.StreamSecurityUpgradeAcceptorBase.AcceptUpgrade(Stream stream)
  at System.ServiceModel.Channels.InitialServerConnectionReader.UpgradeConnection(IConnection connection, StreamUpgradeAcceptor upgradeAcceptor, IDefaultCommunicationTimeouts defaultTimeouts)
  at System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.ServerFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
  at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  at System.ServiceModel.Channels.CommunicationObject.Open()
  at System.ServiceModel.Dispatcher.ChannelHandler.OpenAndEnsurePump()
  at System.ServiceModel.Dispatcher.ChannelHandler.OpenAndEnsurePump(Object state)
  at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2()
  at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.OnSecurityContextCallback(Object o)
  at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
  at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke()
  at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks()
  at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state)
  at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
  at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)


我在配置文件中设置了maxArrayLength和maxStringContentLength很高。其中之一是否可能非常巨大,并导致通道引发此错误?这是一个.NET WCF服务,正在通过IPC与另一个进程进行本地通信。

最佳答案

鉴于这是一个生产问题,并且它偶尔会在不同地方发生,我猜您正在遇到一个高内存利用率问题。我将获得系统的内存转储,并使用WinDbg来查看引起此问题的原因。

您可以使用proc dumpDebug Diag进行此操作(但请确保根据需要使用32位还是64位)。

如果您以前从未对内存进行过分析(这确实不容易),那么您可能想看看this article

10-06 01:59