Home > Computers and Internet > I’m leaking objects, but all of the GC Roots point to a WeakEventTable

I’m leaking objects, but all of the GC Roots point to a WeakEventTable

Recently my team ran into a major performance problem where we were leaking every object in our code. The code is C# and the visuals for the data are done in WPF. Every tool at our disposal pointed to the same fact, all of the objects were being held in memory by a WeakEventTable. It was so odd, one would assume that the type WeakEventTable wouldn’t have the ability to hold onto objects, but it does. It’s the global table mentioned in http://support.microsoft.com/kb/938416. Have you read the KB article? Does it make sense? It doesn’t for me either.

Given how easy it is to create a WPF object which then gets placed in a global table (as described in KB938416) one would think that Microsoft would create tools for detecting this. As far as I can tell they haven’t. This would be a perfect issue to have Visual Studio find with the Code Analysis tool. Warning: You’re going leak everything. I can’t imagine why anyone would ever want an object to live indefinitely, unless they intentionally put it in the global table themselves. It’s so bizzare.

It’s very frustrating how KB938416 is considered by design. It may be by design at the language level, but it shouldn’t be at the tooling level.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: