Wednesday, August 17, 2005

I blogged a few days ago about a crazy problem I had with garbage collection in ASP.net under 2.0.  I finally tracked the problem down to Array.Sort.  I created a framework for working with large sets of data in a dynamic way.  This allows us to group data and do other complex statistical things based on fairly open-ended user input, rather than having to write special case code for each scenario.  It uses some reflection to be able to drill into objects.  When sorting, we pass in a dynamic IComparer that can drill into each object and do dynamic comparisons.  Unfortunately, many of our algorithms were dependent on sorting the data first.  This was causing a huge number of allocations due to drilling in and boxing lots of value types.  And, the nature of the sort causes that to happen multiple times per item.

Under 1.1, we took the hit on memory.  It didn't take that long, and it was soon collected.  Under 2.0, the GC seems to recognize this allocation pattern early and proactively begins collecting aggresively.  The problem seems to be that this slows down the sort tremendously, to the point where it essentially comes to a halt.  After a long time, you get a bizarre looking exception about a failed sort from deep in the framework.

What I can't figure out is, during all this time, there's still plenty of memory, and activity on other requests is not impacted horribly.

Well, I took a long hard look at some of the operations, and re-implemented them with a hashing strategy rather than relying on a sort.  As it turns out, for most cases, this is much more efficient.  Long story short, overnight stress testing turned up with clean results this morning.

posted on Wednesday, August 17, 2005 6:37:49 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
Related posts:
9-year Anniversary (yesterday)
LinqToStdf now on CodePlex
Image Slicer for Deep Zoom in Silverlight 2
Silverlight limitations and Constrained Callvirt in IL
Happy Birthday Peter
What are the generic Delegates in the framework for?
Tracked by:
"Crazy Garbage Collector under .NET 2.0" (marklio) [Trackback]
http://www.marklio.com/marklio/PermaLink,guid,e607db75-50f2-4010-aee0-36dee1c93f... [Pingback]
"used car buying guide quebec" (used car buying guide quebec) [Trackback]
"bone jewellery" (bone jewellery) [Trackback]
"on off on round rocker switch" (on off on round rocker switch) [Trackback]
"star furniture" (star furniture) [Trackback]
"Cheddars Restaurant in Texas" (Cheddars Restaurant in Texas) [Trackback]
"pictures of space" (pictures of space) [Trackback]
"Cancun Women" (Cancun Women) [Trackback]
"money money health health go2clickbank.com" (money money health health go2click... [Trackback]
"1-800 directory" (1-800 directory) [Trackback]
"omega psi phi fraternity songs" (omega psi phi fraternity songs) [Trackback]
"serpent Alchemy dragon lore" (serpent Alchemy dragon lore) [Trackback]
"Swing Life away" (Swing Life away) [Trackback]
"hand crank dynamo" (hand crank dynamo) [Trackback]
"aggiungi sito" (aggiungi sito) [Trackback]
"personal injury lawyer virginia" (personal injury lawyer virginia) [Trackback]
"likable cameriera prostituta" (likable cameriera prostituta) [Trackback]
"naughty college girls gone wild" (naughty college girls gone wild) [Trackback]
"BODY FORTRESS GLUTAMINE" (BODY FORTRESS GLUTAMINE) [Trackback]
"sturgis web cam" (sturgis web cam) [Trackback]
"lava lamps" (lava lamps) [Trackback]
"cascade locks" (cascade locks) [Trackback]
"DMAE Cream" (DMAE Cream) [Trackback]
"Dumb Blonde Jokes" (Dumb Blonde Jokes) [Trackback]
"Keflex lasix" (Keflex lasix) [Trackback]
"the talon tallahassee community college newspaper" (the talon tallahassee commu... [Trackback]
"arc plasma temperature air" (arc plasma temperature air) [Trackback]
"Car Valuation Software Korea" (Car Valuation Software Korea) [Trackback]
"internet payroll solutions" (internet payroll solutions) [Trackback]
"ugg australia in vancouver" (ugg australia in vancouver) [Trackback]
"mini digital video player" (mini digital video player) [Trackback]
"park rapids resort" (park rapids resort) [Trackback]
"PLANE CRASH" (PLANE CRASH) [Trackback]
"alpine aire" (alpine aire) [Trackback]
"quilt hanger" (quilt hanger) [Trackback]