I'm getting a massive memory leak in my app and I'm having a REALLY hard time figuring out where it's coming from. When I use !dumpheap, and then a !gcroot command I get this:
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
where foo.MemoryLeak is the object that I'm using to track the memory leak. Each time I run the action, it creates a form that includes foo.CompoonentSUbEditorUserControl. This user control creates one instance of foo.FooMemoryLeak. I close the form, pause my app and do a:
!dumpheap -type foo.FooMemoryLeak
and each time it reports an extra FooMemoryLeak object. When I use the !gcroot command it shows System.Windows.Forms.Application+ThreadContext as the root that's holding onto my object.
What the heck is Application+ThreadContext and why is it hanging onto my user control (and thereby ALL of the objects that the user control references)?