Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

UI Automation - Memory Leak

$
0
0

I have encountered (what seems to be) memory leaks with the UI Automation Library. To track down the issue, I've stripped down my project to the bare minimum, and I am still able to reproduce the problem.

Originally, there were registered handlers for Structure, Property, Automation and Focus Change Events. But to be sure, I currently am monitoring only FocusChanged Events. Usage started at 41MB working set, 9MB private; and strictly climbs up from there. Adding Automation events only increases the rate at which it grows.

using System;
using System.Windows.Forms;
using System.Windows.Automation;

namespace focus_monitor_test
{
    static class Program
    {
        static void Main()
        {
            UIAListener listener = new UIAListener();
            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            listener.Close();
        }
    }

    public class UIAListener
    {
        public UIAListener()
        {
            Automation.AddAutomationFocusChangedEventHandler(new AutomationFocusChangedEventHandler(OnUIAutomationFocusEvent));
        }


        public void Close()
        {
            Automation.RemoveAllEventHandlers();
        }

        public void OnUIAutomationFocusEvent(object src, AutomationFocusChangedEventArgs e)
        { }

    }

}

I know the problem is not in my code; I ignore all of the events anyway. I have read that events can be stored for 3 minutes until a timer expires. I manually collected garbage, but that does not make a difference.  Thoughts??


Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>