Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm having a peculiar issue where IIS7 has decided to load a massive amount of memory for an otherwise small web page. on each request it adds between 2 and 20MB of memory to the process and I can't for the like of me figure out why. I've looked extensively for memory leaks but I just can't seem to find where this is happening. Does anyone have some suggestions as to what i can do to isolate the problem?

share|improve this question
    
Are you putting any objects into the session variables? –  JamesRyan Oct 29 '09 at 15:33
    
I'm using an out of process session state module. Therefore it will not affect iis, also the session state is a negligable size <20K so there is no reason that it should affct the memory usge of IIS. –  Middletone Oct 29 '09 at 15:39
    
To answer your question, asking for suggestions to isolate the problem, i would start with a new empty web-site, feeding a static web-page. Then begin adding content, code, session variables, etc one by one. –  Ian Boyd Oct 30 '09 at 17:16
    
Similar to: serverfault.com/questions/78629/… –  Ian Boyd Oct 30 '09 at 17:23
    
You may have better luck on stackoverflow.com as this evolves into a programming question. –  Abel Jan 7 '10 at 11:25

3 Answers 3

up vote 1 down vote accepted

What you need is a memory profiler. A good memory profiler, that audits your .NET code, will point you to the objects, and the places in the code where they're allocated, that take the most memory. Without such tool it is very hard, or even impossible, to pinpoint the actual problem (think hours or days, instead of weeks).

You can say that all database connections are closed and disposed off, but is that really true? Do you use a using-statement around all disposable objects (any object that implements IDisposable can leak resources, including memory)? There are code review tools around that can help you analyze your code for you (think ReSharper).

Some profilers:

If I remember well, I got the best results using YourKit (it gives the smallest overhead, but that's still significant on live servers). Many other memory and performance profilers exist for .NET.

share|improve this answer

Finding the source of the memory isn't easy if you don't know how to do it. (Me neither...)

You might want to try to see if you can find out what code causes this:

  • Does it happen when you create a new application with just a Hello World script?
  • Does it happen on a specific page or every page in your website?

You probably want to read into: Configuring Recycling Settings for an Application Pool (IIS 7).
And in your case: Recycling when reaching a request limit.

share|improve this answer
    
these are dynamic pages and I've verrified that all connections to the database are closed and disposed of. –  Middletone Oct 29 '09 at 15:39
    
also i shouldn't have to recycle the app after 10 requests. that's rediculous. –  Middletone Oct 29 '09 at 15:41
    
If recycling doesn't help then try garbage collecting at the end as a temporary solution. I would suggest to use debugging with WinDBG and SOS as this should be easier than native due to the .NET Framework, check google.be/search?q=ASP.NET+WinDBG+Memory (The First link) and geekswithblogs.net/.netonmymind/archive/2006/03/14/72262.aspx (A handy Cheat Sheet). I can remember that Visual Studio or an external application had this kind of features too, but it might be for client applications only. –  Tom Wijsman Oct 29 '09 at 15:48

Have you tried using any .NET memory profilers? That might be less painful than using WinDBG to track what the memory is being allocated to.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.