Memory leaks 我需要帮助找出内存泄漏的根源
问题:为什么会发生内存泄漏?是什么原因造成的?如何修复它 我有一个运行着1个网站的服务器。它托管在32位应用程序池中。启动到2-3 Gb后,它会在内存中增长。从这2-3 Gb中,1-1.5 Gb是托管代码的内存,我们正在处理它,但其他1-1.5 Gb是webengine4模块分配的本机内存。我假设它是某个IIS模块(来自DebugDiag 1.2的输出): 按分配大小排列的前4项功能Memory leaks 我需要帮助找出内存泄漏的根源,memory-leaks,iis-7.5,windows-server-2008-r2,Memory Leaks,Iis 7.5,Windows Server 2008 R2,问题:为什么会发生内存泄漏?是什么原因造成的?如何修复它 我有一个运行着1个网站的服务器。它托管在32位应用程序池中。启动到2-3 Gb后,它会在内存中增长。从这2-3 Gb中,1-1.5 Gb是托管代码的内存,我们正在处理它,但其他1-1.5 Gb是webengine4模块分配的本机内存。我假设它是某个IIS模块(来自DebugDiag 1.2的输出): 按分配大小排列的前4项功能 webengine4!W3_MGD_BUFFER_POOL::RentBuffer+1a 1,29 GByte
webengine4!W3_MGD_BUFFER_POOL::RentBuffer+1a 1,29 GBytes
webengine4!BUFFER::ReallocStorage+34 90.82 KBytes
webengine4!MemAlloc+24 63.45 KBytes
webengine4!MemAllocClear+24 400 Bytes
示例调用堆栈:
Function
webengine4!W3_MGD_BUFFER_POOL::RentBuffer+1a
webengine4!MgdGetBuffer+11
System.Web.HttpResponseUnmanagedBufferElement..ctor()
System.Web.HttpWriter.BufferData(Byte[], Int32, Int32, Boolean)
System.Web.HttpWriter.WriteFromStream(Byte[], Int32, Int32)
System.IO.Compression.DeflateStream.InternalWrite(Byte[], Int32, Int32, Boolean)
System.IO.Compression.DeflateStream.Write(Byte[], Int32, Int32)
System.IO.Compression.GZipStream.Write(Byte[], Int32, Int32)
System.Web.HttpWriter.FilterIntegrated(Boolean, System.Web.Hosting.IIS7WorkerRequest)
iiscore!`WWWServerTraceProvider::GetProviderGuid'::`2'::ProviderGuid
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, Int32 ByRef, Boolean ByRef, Int32 ByRef)
clr!InlinedCallFrame::`vftable'
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
clr!InlinedCallFrame::`vftable'
0x31E672
0x31E672
0x31E5CD
System_Web_ni+1d1dac
clr!FastNExportExceptHandler
webengine4!__delayLoadHelper2+376
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+190
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+305
iiscore!NOTIFICATION_CONTEXT::CallModules+28
iiscore!W3_CONTEXT::DoStateGeneralEvent+36
iiscore!W3_CONTEXT::DoWork+c6
iiscore!W3_MAIN_CONTEXT::ContinueNotificationLoop+1f
iiscore!W3_MAIN_CONTEXT::ProcessIndicateCompletion+1f
iiscore!W3_CONTEXT::IndicateCompletion+75
webengine4!W3_MGD_HANDLER::IndicateCompletion+3d
webengine4!MgdIndicateCompletion+24
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)
clr!InlinedCallFrame::`vftable'
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)
clr!InlinedCallFrame::`vftable'
clr!ContextTransitionFrame::`vftable'
0x31E5CD
System_Web_ni+1d1dac
clr!UM2MThunk_WrapperHelper+10
clr!UM2MThunk_Wrapper+8c
clr!Thread::DoADCallBack+f0
clr!UM2MDoADCallBack+c0
0x31E628
clr!FastNExportExceptHandler
clr! ?? ::FNODOBFM::`string'+26ffa
clr!ThreadpoolMgr::WorkerThreadStart
clr!SlowClrFlsSetValue+42
clr! ?? ::FNODOBFM::`string'+41b4f
clr!ThreadpoolMgr::WorkerThreadStart
clr!ThreadpoolMgr::WorkerThreadStart
clr!operator delete+41
clr!ThreadpoolMgr::WorkerThreadStart
clr! ?? ::FNODOBFM::`string'+41bd8
clr!Thread::intermediateThreadProc+4b
kernel32!BaseThreadInitThunk+e
ntdll!__RtlUserThreadStart+70
ntdll!_RtlUserThreadStart+1b
clr!Thread::intermediateThreadProc
我们也有这样的例外(但我认为,它们更简单,然后才是原因):
我试过了,但没有找到任何相关信息。有人能帮我吗?问题解决了
我们确定IIS worker由于数据急剧增长而承受着沉重的CPU和内存压力,所以GC没有足够的资源来完成它的工作。当我们正在进行真正的修复时,我可以向任何处于类似解决方案的情况下的人提出建议:我们添加了额外的工作进程(我们的服务器是无状态的),它们在它们之间分配内存压力,因此GC可以工作,而非托管内存也消失了。我今天遇到了同样的问题,你能帮助我吗,如何解决这个问题。。。我尝试增加工作进程,但没有用。。。现在,两个工作进程都占用3 GB的空间RAM@51k这是一个很长的时间,我不记得任何真正的细节问题,抱歉。我只能假设问题出在工作速度慢(CPU负载重)的情况下,因此请求队列已满并占用内存。尝试对此进行调查,但如果没有帮助,请道歉。
Exception type: OutOfMemoryException
Exception message: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Web.HttpResponseUnmanagedBufferElement.System.Web.IHttpResponseElement.GetBytes()
at System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr)
at System.Web.HttpResponse.FilterOutput()
at System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)