UIAutomation Memory Issue UIAutomation Memory Issue wpf wpf

UIAutomation Memory Issue


After talking to Microsoft customer support, we found the answer to the problem. Internally, WPF gives itself three minutes to respond to a UI Automation event. To do this, it starts off a timer. It appears that even if the event is responded to immediately, the timer does not go away until after the three minutes are up.

So, the workaround to the problem is to wait until the timer expires and then do a GC.Collect. Then the memory issue will go away. Not a great fix, but it works for our situation.


Try to declare the objects such as buttonElement, and invokePattern outside of the for loop.