I am using Microsoft.Practices.Unity framework 1.2 and I can see the memory usage dramatically increasing over time. I’ve been watching the Garbage Collector heap sizes for Gen 0, 1 and 2 and Objects seems to be continuously promoted to Gen 2 where they stay and get older and older without been claimed by the GC.
Is there some tuning I could do for avoiding this excessive memory consumption?
How do you know it’s due to unity framework? It’s possible your injected instances are not being disposed properly. I suggest RedGate Memory Profiler as it will tell you exactly what is not being collected. Memory leaks are a PITA and i’ve been dealing with them for the last 2 weeks.
Event handlers are usually the cause of these types of issues. Make sure you manually remove all event handlers.
I’ve found that the GC is not as great at cleaning things up as you might have thought.