views:

71

answers:

3

What can cause an IIS worker process to grow uncontrollably?

I've got a bug where if I take a page and load it sometimes it adds no memory, a small amount of memory (250k-2MB) or a really large amount of memory (10MB-30MB). I have no idea what is causing this but if you can brainstorm what might cause this behaviour I'd appreciate it.

EDIT

So apparently you can't cache a .net control and pull it from the cache without it somehow leaking memory. I was trying to cache a menu control which was causing the memory to go up every time it was requested from the cache. the solution in this case was to put the items into an array or a dictionary and cache that instead and then re-create the items when the page was loaded. This resolved the memory leak and is why I had so much trouble locating it.

+1  A: 

Could be a whole chunk of causes. Could be you are creating extra sessions so its allocating more memory, you are not cleaning up some objects in your code, has to get a new connection to a DB rather than reuse one, allocating extra memory to absorb expected load (if you are hitting it alot in a short time you might be trigging some pro-active memory management?)...and the list goes on.

Is it gobbling up the same about every time? Does teh process grow and grow?

Is it just that one page? Have you created an empty page and monitored if that does the same? Then tried commenting out various bits of your problem page to see if you can isolate the program? Switched Trace on and watched whats getting called and when? Any suspect?

Lots of places to look...Also might be woth posting this over on serverfault.com too

Pete Duncanson
+2  A: 

Without knowing anything about what your application does it's kind of hard to say if you've got a leak or whether this is just the natural working memory use for the application.

You might want to run your application through a memory profiler such as Red Gate's Ants Memory Profiler

Also Tess Ferrandez has some great articles on debugging memory leaks.

Kev
A: 

Can you post the code for the page, or at least a snippet the loading and initialization of the page?
Here are some steps that might help:

  1. The variable results you are reporting the first point of call might be review of an static resources or methods you call and check what initialization processes might be associated with those.
  2. Check that your application is the only one using that specific application pool and that no one else is connected.
  3. Make sure you have no debugging tools attached. Check your code and make sure all loops are being exited correctly, that you have no recursion going on, and that all resources are always accessible and local.

Maybe this will help, but it is hard to say without seeing the code you are using.

Cheers

Mike