I've noticed that any time the UI Automation Focus Change event is hooked, Internet Explorer will leak memory with every page load. This only happens on Server 2019, which is an issue when running thin clients. Is there any solution to this issue?
Environment:
Windows Server 2019 Standard V 10.0.17763 Build 17763
Internet Explorer 11 Version 11.678.17763.0 Update Version 11.0.140 (KB4511872)
Sample console application to trigger the memory leak:
Program.cs:
using System; namespace UIAWorkBench { class Program { static void Main(string[] args) { UIAutomationWorker worker; Console.WriteLine("Starting Watcher ..."); worker = new UIAutomationWorker(); Console.WriteLine("Subscribe Focus Change Event"); worker.SubscribeFocusChange(); Console.WriteLine("Watching ..."); Console.ReadLine(); } } }
UIAutomationWorker.cs:
using System; using System.Windows.Automation; namespace UIAWorkBench { class UIAutomationWorker { public UIAutomationWorker() { } public void SubscribeFocusChange() { try { // Hook Focus Change Event Automation.AddAutomationFocusChangedEventHandler(UIAFocusChange); } catch (Exception ex) { throw ex; } } private void UIAFocusChange(Object sender, AutomationFocusChangedEventArgs e) { // Do Nothing } } }