IIS7/.NET Memory Leaking – Is Worker Process Recycling The Only Long Term Fix

.net-4.0iisiis-7worker-process

I have a problem with a .NET 4 application leaking memory. It's not a "forgot to clean it up" leak in the normal sense, they are doing compiles that create a bunch of .NET assemblies in memory and they tell me there's no way to clear them out after. So it's now up to me to keep the service going.

So I'm faced with a couple options. There's the "set IIS worker processes to recycle when the memory gets large." That will help, but to me it seems like still an inherently metastable system, and there's user impact while the pool is recycling, isn't there?

They tried breaking out the compiles into separate temporary app domains, but then each operation is pretty slow, it adds ~15 seconds per hit to spawn the app domain. So they don't want to do that.

Is there anything other than "recycle a lot" I can do from the system side to mitigate this problem in a more permanent way? (Or app ideas, but that's more for SO.)

Best Answer

That sounds like a typical programming error. Move the to unload assemblies to their own appdomain and you are fine. This is what I do for stuff like plug ins etc. that I need to be able to unload.