question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UI Automation can cause unbounded memory consumption

See original GitHub issue
  • .NET Core Version: 3.1.200

  • Have you experienced this same bug with .NET Framework?: Yes

Problem description:

The WinForms control expose UI Automation interfaces through WM_GETOBJECT. They, however, don’t call the UiaDisconnectProvider API when the controls are destroyed (SDK sample). It does call UiaReturnRawElementProvider as specified in the documentation but that does not release any providers that are still held by the UI Automation clients. The clients can still hold on to the COM objects and thus keep the lifetime much longer than the actual lifetime of the controls and forms. This is problematic because it can cause massive memory consumption because the controls and forms cannot get garbage collected.

The old way of handling this was breaking up the references between the automation proxies and the actual controls and returning UIA_E_ELEMENTNOTAVAILABLE error from the COM entry points. This could possibly be implemented in quite transparent way in the InternalAccessibleObject class.

The newer way of handling this is asking UIA to release any references to the interface when the form/control is destroyed using the UiaDisconnectProvider API.

The behavior can be checked by the VisualUIAVerifyNative.exe tool that is part of the Windows SDK.

Examples:

Label control on a live form in UIA Verify:

image

Label control on a closed form in UIA Verify:

image

Different control in UIA Verify after the form was closed and UiaDisconnectProvider was called:

image

Expected behavior:

UI Automation clients should not leak memory through the server-side UIA providers on disposed controls.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
weltkantecommented, Jun 4, 2020

In some cases we saw UIA calls even if the customer claimed not to use any screen reader software.

When I’ve been debugging WinForms going through automation API was the common case not the exception. Windows itself is very happy to use UI automation for various purposes, for example the onscreen keyboard will go through the automation API, there are probably more common tools that use it but I’m not actively aware of them, mostly because I didn’t bother figuring out who is causing the automation API calls. (I’m only aware of the onscreen keyboard because it broke our DevExpress based application once and I had to figure out what happened.)

PS: above statement doesn’t differentiate between individual automation APIs, I’m just talking about automation as a concept being commonly activated these days.

0reactions
RussKiecommented, Jun 4, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak when using UI Automation tests
I am running into a memory issue when running my UI automated tests with XCTestCase ... Or does this seem like a memory...
Read more >
Memory leak when using UI Automation in Windows 10
I'm experiencing a memory leak on Windows 10 machine and after investigation of some dump taken from the process causing the issue (a...
Read more >
MemLab: An open source framework for finding JavaScript ...
We've open-sourced MemLab, a JavaScript memory testing framework that automates memory leak detection. Finding and addressing the root cause ...
Read more >
Memory Leak in Target Silverlight App via AutomatonPeer ...
Hello, We're seeing memory leaks in our Silverlight OOB application whilst running tests using Ranorex 5.1.2.19431 . Using memory profilers we're seeing ...
Read more >
Detecting and Managing Memory Leaks
Consequently, there is unbounded growth in memory consumption, as you're piling up references to objects that are no longer used, but which can' ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found