0

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?

5
  • Are you putting any objects into the session variables?
    – JamesRyan
    Oct 29, 2009 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, 2009 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, 2009 at 17:16
  • Similar to: serverfault.com/questions/78629/…
    – Ian Boyd
    Oct 30, 2009 at 17:23
  • You may have better luck on stackoverflow.com as this evolves into a programming question.
    – Abel
    Jan 7, 2010 at 11:25

3 Answers 3

1

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.

1

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.

3
  • these are dynamic pages and I've verrified that all connections to the database are closed and disposed of.
    – Middletone
    Oct 29, 2009 at 15:39
  • also i shouldn't have to recycle the app after 10 requests. that's rediculous.
    – Middletone
    Oct 29, 2009 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. Oct 29, 2009 at 15:48
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .