我在 Windows 10 机器上遇到内存泄漏,在调查了从导致问题的进程(WPF 应用程序)中提取的一些转储后,我发现了许多“MS.Internal.Automation.SynchronizedInputProviderWrapper”实例,基本上大多数对象都保存在此类型引用了内存而不是收集的垃圾。
我一直在使用 dotMemory(实例的密钥保留路径)、Visual Studio 2019(用于转储比较)和 WinDbg 进行进一步调查。
根据这个stackoverflow答案: UIAutomation Memory Issue
他们是在 Win 8 RT 和 windows 2012 服务器上修复问题的汇总:https: //support.microsoft.com/en-us/help/2885482/memory-leak-when-using-ui-automation-in-windows- 8
根据微软的说法:请参阅此链接
当使用 UI 自动化框架的多个应用程序同时在基于 Windows 8 的计算机上运行时,会发生内存泄漏,并且您会遇到高 CPU 使用率。
而且我认为这在 Windows 10 上也可能是相同的问题,但找不到解决此问题的修复程序或汇总。
更新:
我对 SuperDump 进行了另一次分析,发现了内存泄漏的潜在解释,但我无法解释调用堆栈:
clr!EEHeapAlloc+2c ntdll!RtlAllocateHeap
clr!EEHeapAllocInProcessHeap+5b clr!EEHeapAlloc
clr!ClrAllocInProcessHeap+23
clr!operator new+14 clr!ClrAllocInProcessHeap
clr!ComCallWrapper::CreateWrapper+1ce clr!operator new
clr!ComCallWrapper::InlineGetWrapper+24 clr!ComCallWrapper::CreateWrapper
clr!GetComIPFromObjectRef+22e clr!ComCallWrapper::InlineGetWrapper
clr!MarshalObjectToInterface+3a clr!GetComIPFromObjectRef
clr!StubHelpers::InterfaceMarshaler__ConvertToNative+d8 clr!MarshalObjectToInterface
0x4AA1110 clr!StubHelpers::InterfaceMarshaler__ConvertToNative
PresentationCore_ni!System.Windows.Media.DashStyle.OffsetPropertyChanged(System.Windows.DependencyObject, System.Windows.DependencyPropertyChangedEventArgs)$##6001EA6 <PERF> (PresentationCore_ni+0x19cca0)
clr!COMToCLRDispatchHelper+6b
clr!COMPlusFrameHandlerRevCom
UIAutomationCore!RichEditObjectProxy::QueryInterface+6139
UIAutomationCore!NullInvoker::CallTarget
UIAutomationCore!InProcClientAPIStub::UiaNode_GetPatternProvider
UIAutomationCore!RichEditObjectProxy::QueryInterface+6116
UIAutomationCore!InProcClientAPIStub::InvokeInProcAPI+5eb
UIAutomationCore!UiaNode::CrossProcess_GetPatternProvider+49 UIAutomationCore!InProcClientAPIStub::InvokeInProcAPI
UIAutomationCore!RemoteUiaNodeStub::Incoming_GetPatternProvider+8c UIAutomationCore!UiaNode::CrossProcess_GetPatternProvider
UIAutomationCore!RemoteUiaNodeStub::OnMessage+b8
UIAutomationCore!InvokeOnCorrectContext_Callback+272
UIAutomationCore!NullInvoker::CallTarget+2b UIAutomationCore!InvokeOnCorrectContext_Callback
UIAutomationCore!ProcessIncomingRequest+4f6
UIAutomationCore!ChannelBasedServerConnection::OnData+dd
UIAutomationCore!ReadWriteChannelInfo::Service+18a UIAutomationCore!ChannelBasedServerConnection::OnData
UIAutomationCore!OverlappedIOManager::IoThreadProc+b3 UIAutomationCore!ReadWriteChannelInfo::Service
UIAutomationCore!OverlappedIOManager::StaticIoThreadProc+d UIAutomationCore!OverlappedIOManager::IoThreadProc
kernel32!BaseThreadInitThunk+19
ntdll!__RtlUserThreadStart+2f
ntdll!_except_handler4
ntdll!FinalExceptionHandlerPad22
UIAutomationCore!OverlappedIOManager::StaticIoThreadProc
谢谢