Sitemap memory consumption

Oct 13, 2011 at 9:43 PM
Edited Oct 16, 2011 at 9:22 AM


 I am generating a very large dynamic site map from code around 60k nodes.

At runtime the application pool seems to take around 1.5G of RAM when it starts, it even goes over this after a wile.

Typical dynamic provider code looks like this:

public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
            // Create a node for each city
            foreach (var state in states)
                foreach (var city in state.Cities.Where(c => !c.IsDeleted))
                    DynamicNode node = new DynamicNode(city.GetCityNodeKey(state), city.Name)
                                               Title = city.Name.Encode(), 
                                               ParentKey = state.GetStateNodeKey()
                    node.RouteValues.Add("cityId", city.Id);
                    yield return node;
            yield break;

I am sure this is what is causing the issue, because if I comment yield return node in the above code my memory falls back to normal.

Can someone give me a hand with this, please ?




After some memory profiling it turns out that the LOH is heavily fragmentated, there is a known issue with LOH fragmentation in the .net framework.

Anyone out there with a large dynamic sitemap, how does this work out for you ?