Daniel Taiber
Daniel Taiber

Reputation: 93

Asp.net memory bloating unexpectedly

We have an Asp.NET application holding all of our server logic. This application only accommodates the services (no pages).

From some reason after some time the w3wp.exe process memory consumption tends to bloat. It grows in a matter of seconds to the maximum size availble (in my server up to 10 gigabytes).

It happens unexpectedly, so we can't really recreate by demand.

I need some help with debugging this issue. Does anyone know of a good tool i can use? maybe something i can tell to dump the memory or take a snapshot when the process reaches some memory consumption.

Any help will be appreciated. Daniel

Upvotes: 1

Views: 202

Answers (4)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65471

There are many good answers here on debugging.

Another way to approach the problem is using a code review.

There are many ways that memory can leak in a program. But for it to leak several GB in a few seconds is almost certainly due to a loop in your code.

So:

  • Identify all the loops in your code
  • first see if you can see the problem just by looking at it
  • if not place a logging call that will log each iteration
  • deploy and wait for the next time it happens
  • check the logs to see where the run away loop is

Upvotes: 2

Aaron Barker
Aaron Barker

Reputation: 706

If you can make it happen in a development environment then you should be able to use Visual Studio's built in profiling tools to track down the issue.

If this only happens in your production environment check this out: https://rpm.newrelic.com

Upvotes: 1

lnmx
lnmx

Reputation: 11164

Tess Ferrandez's blog is a great resource for debugging ASP.NET:

There are various ways to capture a memory dump that you can inspect with WinDbg and SOS offline:

http://www.wintellect.com/CS/blogs/jrobbins/archive/2010/06/17/how-to-capture-a-minidump-let-me-count-the-ways.aspx

Upvotes: 0

3Dave
3Dave

Reputation: 29071

Red Gate makes some very nice .NET profiling tools. I believe the memory profiler (which should help you find leaks) has an eval version that may be useful.

Some simple things to check:

  1. Are you allocating any IDisposable objects (HttpWebRequest, WCF objects, anything that uses unmanaged resources or unsafe code) and not disposing them?

  2. Do you have any queries that might be trying to load an entire very large table into RAM? (Unlikely) Check memory usage around any LINQ code that's manipulating SQL results.

Upvotes: 2

Related Questions