A little background...
I am developing a UI automation app that randomly interacts with controls on our UI. Both the app and the UI being automated are WPF applications. I am using the UI Automation accessibility framework. Occasionally I get an ElementNotAvailableException in my app which I catch and handle. When profiling our UI using ANTS 7, I have noticed these exceptions are showing up on the Gen 2 garbage heap. The new instances of the exception match the number of times I caught the exception in my app.
I have looked at the GCRoot using WinDBG, the UIAutomation pages, and I have not found a clear explanation as to why a caught exception is appearing in the app being automated. The objects are not released when the UI is being automated and even remain when I close my automation app.
Any ideas?