Aug 14, 2011
tom

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

Question

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.)

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.

Related posts:

  1. Memcached possibly leaking memory
  2. IIS7: How to handle application pools which uses too much memory or CPU?
  3. Munin locking Ubuntu with long processing times. How to fix?
  4. Is it save to kill a specific w3wp (IIS Worker) process in Task Manager on IIS 7, Windows 2008 Server?
  5. What does recycling the app pool actually do exactly?

Leave a comment