CLR类中的内存泄漏 [英] Memory leak in CLR classes
问题描述
我发生了内存泄漏,并将其追溯到CLR中的此字段:
I have a memory leak and traced it to this field inside CLR:
Microsoft.CSharp.RuntimeBinder.RuntimeBinder.s_instance.m_semanticChecker .globalSymbolContext.GlobalSymbols.tableGlobal.dictionary
Microsoft.CSharp.RuntimeBinder.RuntimeBinder.s_instance.m_semanticChecker.globalSymbolContext.GlobalSymbols.tableGlobal.dictionary
可以使用以下规范在调试器中查看:
It can be viewed in debugger using this specification:
((Microsoft.CSharp.RuntimeBinder.Semantics.LangCompiler)(Microsoft.CSharp.RuntimeBinder.RuntimeBinder.s_instance.m_semanticChecker))。globalSymbolContext.GlobalSymbols.tableGlobal.dictionary
((Microsoft.CSharp.RuntimeBinder.Semantics.LangCompiler)(Microsoft.CSharp.RuntimeBinder.RuntimeBinder.s_instance.m_semanticChecker)).globalSymbolContext.GlobalSymbols.tableGlobal.dictionary
在执行应用程序期间,此字典会无限期地增长。
During execution of application, this dictionary indefinitely grows.
任何想法,该字段的用途是什么以及为什么可以增长?
Any ideas, what exactly this field is used for, and why it can grow?
UPD有没有动态创建类型,至少在我的代码中
UPD there is no dynamic creation of types, at least in my code
推荐答案
到目前为止找到的最好答案:
问题发生在Excel VSTO Range.Style属性附近(它使用动态数据类型)。
每次这段代码
The best answer I've found so far:
The problem happens somewhere around Excel VSTO Range.Style property (it uses dynamic data type).
Every time this piece of code
range.Style == null
运行,它使活页夹
但是如果我这样重写这段代码
runs, it makes the binder consume some more memory.
But if I rewrite this code like this
(Style)range.Style == null
然后问题消失了。
UPD向Microsoft https://connect.microsoft.com/VisualStudio/feedback/details/861770/memory-leak-when-using-excel-add-in-api#tabs
UPD reported this to Microsoft https://connect.microsoft.com/VisualStudio/feedback/details/861770/memory-leak-when-using-excel-add-in-api#tabs
这篇关于CLR类中的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!