views:

368

answers:

6

I have an ASP.NET 2.0 application that spends an excessive amount of time in garbage collection, over 40%, when load tested on a production grade server (dual quad-core, 4g). I have been trying to isolate the problem but it is a large, complex code base making for slow going. There are no GC.Collect() calls. Which tools, techniques, etc. are helpful when trying to isolate this type of problem?

A: 

Well, first off, my trick knee is acting up, and when it does that, it either means it's about to snow, or someone has been using a lot of "+" operators for string concatenation instead of using StringBuilder as the good lord intended.

What about ANTS Profiler? I'd used that a while back and liked it. There's also a Profiling API you can use to catch your own data.

Dave Markle
+3  A: 

Start off by profiling your app using the .Net CLR Profiler (it's got a spiffy GUI for displaying collected data and it's FREE!). Specific instructions for how to profile ASP.Net app can be found here and this article is a good overview of the GC with respect to memory/performance problems, profiling, and the .Net CLR Profiler.

Tautologistics
+2  A: 

Try seeing if someone on your team has actually overridden Dispose() methods to frequently call GC.Collect(). This happened on my team and it got so bad that one of the Dispose() methods took 1 whole second to execute.

This is the only way I could imagine your server spending 40% of its time in garbage collection.

Jon Limjap
+6  A: 

I've found the debugging labs on Tess Ferrandez's blog very helpful when looking at these sorts of issues.

Darren
That site is fantastic. This question actually made me think of http://blogs.msdn.com/tess/archive/2006/06/22/asp-net-case-study-high-cpu-in-gc-large-objects-and-high-allocation-rates.aspx, but you beat me to it. :)
Tadmas
A: 

I've found the GC to use up 100% CPU time, shortly before the entire app crashed. The problem was an 'object leak' where we leaked 20mb at a time. Eventually the GC gave up trying and memory was exhausted.

You can see how long its doing this using perfmon, there is a GC object with quite a few counters.

gbjbaanb
+1  A: 

Thanks to an answer from Darren I found this article on Tess Ferrandez's blog http://blogs.msdn.com/tess/archive/2006/06/22/643309.aspx that pretty well sums up how to chase down problems like this one.

Jim