Problems seem to occur in batches. Last week the hot topic was OutOfMemory exceptions.
I got a memory dump that a customer took around the time they were getting OutOfMemory exceptions. I asked them to collect some performance counters so that we could figure out what this leak was all about.
The performance counters we got were
The picture below shows the output.
The line that keeps increasing matches “Current Assemblies”. Now this is strange since usually after a while this should stop increasing. So it appears we are having assembly leaking.
Let’s try to find what these assemblies are.
At the time this memory dump was taken we had almost 2000 dynamic assemblies in memory. Digging into some of these assemblies ...
And opening them with Lutz Reflector we find a pattern
After talking with dev teams and doing some search in source code we found that this assembly is being generated in source code.
If you look at
you can see
(…) After calling the get accessor, the compiled assembly cannot be deleted until the current AppDomain is unloaded.
So some possible solutions are:
· Try some caching mechanism (if it´s possible)
· Load this assemblies into a separated domain so that you could unload it
· Do you really need to generate this assembly?