1

質問: なぜメモリ リークが発生するのですか? 何が原因ですか?それを修正する方法は?

1 つの Web サイトを実行しているサーバーがあります。32 ビット アプリケーション プールでホストします。また、起動後に最大 2 ~ 3 Gb のメモリが増加します。これらの 2 ~ 3 Gb のうち、1 ~ 1.5 はマネージド コードのメモリであり、現在取り組んでいますが、他の 1 ~ 1.5 Gb は webengine4 モジュールによって割り当てられたネイティブ メモリです。IIS モジュール (DebugDiag 1.2 からの出力) だと思います。

割り当てサイズ別の上位 4 つの関数

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 

そして、そのような例外があります(しかし、私は、それらはより単純であり、原因であると思います):

    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)

私は試してみましたが、これに関する情報は見つかりませんでした。誰でも私を助けることができますか?

4

1 に答える 1

0

問題は解決された。

データの急激な増加により、IIS ワーカーが CPU とメモリの過負荷にさらされていることが判明したため、GC は作業を行うための十分なリソースを持っていませんでした。私たちは実際の修正に取り組んでいますが、回避策のような状況にある人には誰にでも提案できます: 追加のワーカー プロセスを追加し (私たちのサーバーはステートレスです)、それらの間でメモリ プレッシャーを分割したので、GC が機能し、管理されていないメモリもなくなりました。

于 2013-07-23T17:05:40.867 に答える