In the constructor of XamPropertyGrid, it looks like there is a call to add an event handler to a static event (TypeDescriptor.Refreshed).
IE. I can put a breakpoint in the debugger and I see this method call:
System.ComponentModel.TypeDescriptor.add_Refreshed
There is never an equivalent call to release/unsubscribe from that event handler.
The result is that my app has a very rapid leak. Below is an image of the path to the rooted reference. I suppose I may have to do manual cleanup to remove the XamPropertyGrid control from my ProductDetailsControl as a workaround. But even then it will still have a leak of the XamPropertyGrid instances themselves...
Can anyone suggest any easy workarounds?
Hello David,
It appears that this forum thread is essentially a duplicate to a private support case that you submitted that I have very recently answered and logged a development issue for. I will post a summary transcript of the answer I posted to the support case below:
I have been investigating into the sample project you have provided, and I have reproduced this issue. The workaround to this would normally be to either derive a custom XamPropertyGrid and use reflection to get the event handler for TypeDescriptor.Refreshed to unhook it when the XamPropertyGrid is unloading, but this unfortunately won't work, and I cannot recommend a known workaround for this. The reason it will not work is because of the way this event is hooked in our source code – it is using an anonymous lambda expression event handler, and so I cannot get it using reflection. It is hooked like so:
TypeDescriptor.Refreshed += (e) => { this.PropertyDescriptorCollectionCache.Clear(); };
This is unexpected behavior, and as such, I have asked our engineering staff to examine it further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 262191. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
It is also worth noting that version 2017.2 has had its final service release, and so this issue will not be fixed in 2017.2. Actually, the earliest version that this will be fixed in will actually be 2018.2, as the final 2018.1 service release has been finalized as of yesterday and is now undergoing testing. You can see this from the product lifecycle page, here: https://es.infragistics.com/support/product-lifecycle.
Please let me know if you have any other questions or concerns on this matter.
Yes, thanks Andrew. I wanted to also post the problem (and eventual resolution) in the open forum. I didn't find any mention of it yet, and this issue would presumably affect every WPF customer using the XamPropertyGrid.
I always like to see problems being solved out in the open. If a google search can give a quick answer to a problem like this one, then it is easy to save some other developer a lot of time (days/weeks) that they might otherwise be interacting with tech support.
... I know there have been many times that I've been able to benefit from public information about well-known bugs (whether in third-party forums or KB's or blogs or whatever).