I've got a memory problem in my .NET application where my app starts off consuming about 1GB in the Gen2 heap after everything is initialized and loaded. It slowly over time (4-5 hours) ends up consuming 4GB in the Gen2 heap. I've used WinDbg to analyze things that I see that some of my object types (and associated memory usage) are increasing.
All of the objects that growing in instances (and mem usage) are referenced by the same parent object type. This parent object type has about 3900 instances - this never changes. Somehow, I'm adding child objects to some of these parent instances, but I don't have a good way to see which of the 3900 instances are being added to.
!DumpHeap -mt will show me all my parent types, but the sizes are all the same because it doesn't count children.
!ObjSize will count the size of the children too, but will only take one object at a time for an argument (or all objects of all types - not just my parent type - which is way too many objects)
Looking at the child objects and tracing them back to the parent isn't helpful either because there are a couple million of these types and I don't see a way to do some kind of aggregate trace.
Tools like CLRProfiler and ANTS slow down my app too much (ANTS less so) to make the problem happen in any reasonable amount of time.
I have tried running my application with a small subset of data that it normally runs on in order to make debugging easier, but I don't get memory issues here. I think there are some edge cases in my entire data set that cause strange things, but I don't know what those edge cases are in order to isolate them into a subset of my entire data set.
Have read widely on this and can't see anyone suggesting what to do when are LOTS of objects in Gen2 that are supposed to be there and a small amount of objects of the same type that keep increasing.
Any tips would be most appreciated.