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
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
During execution of application, this dictionary indefinitely grows.
Any ideas, what exactly this field is used for, and why it can grow?
UPD there is no dynamic creation of types, at least in my code
DEFINITION A memory leak is the gradual deterioration of system performance that occurs over time as the result of the fragmentation of a computer's RAM due to poorly designed or programmed applications that fail to free up memory segments when they are no longer needed.
The memory leak would occur if the floor number requested is the same floor that the elevator is on; the condition for releasing the memory would be skipped. Each time this case occurs, more memory is leaked. Cases like this would not usually have any immediate effects.
There are two types of memory leaks: apparent and subtle. An apparent memory leak is a chunk of heap memory that's never referred from active memory, a subtle leak is memory that is still referred to but shouldn't be, i.e. a hash or dynamic array holds the references.
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
then the problem disappears.
UPD reported this to Microsoft https://connect.microsoft.com/VisualStudio/feedback/details/861770/memory-leak-when-using-excel-add-in-api#tabs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With