Possible Memory Retention Issue with SyntaxEditor and Automation Peers

SyntaxEditor for WPF Forum

The latest build of this product (v24.1.5) was released 2 months ago, which was before this thread was created.
Posted 4 days ago by Stefano
Version: 24.1.5
Platform: .NET 6.0
Environment: Windows 11 (64-bit)
Avatar

Hello,
We’ve observed that SyntaxEditor instances may remain in memory longer than expected after disposal, and memory profiling points to *.Automation.Peers.* as potential references. We're unsure of the exact root cause, but it resembles some issues with WPF UI Automation behavior that we have found.

Here are some related discussions we found:

Here is a screenshot of what we find in the Visual Studio memory profiler: https://ibb.co/CK7DH0C7
In one case, a workaround mentioned waiting ~3 minutes (due to an internal timer) before calling GC.Collect(), which aligns with some of our testing.

Do you have any guidance or recommended approaches for handling this scenario with SyntaxEditor?

Thanks

[Modified 4 days ago]

Comments (3)

Posted 3 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Unfortunately, this appears to be an issue with how WPF is implemented, so we don't have any specific recommendations related to SyntaxEditor.  It does at least appear that the memory will eventually be recovered, even if it is not as quickly as one might hope.

It appears the only way to "resolve" this is to effectively disable UI automation by creating a custom AutomationPeer for each control that essentially does nothing.  Even if it was possible to track down and replace each AutomationPeer used by our controls, this is not something we would recommend since it also means the controls will stop working with screen readers and other accessibility software.


Actipro Software Support

Posted 3 days ago by Stefano
Avatar

Understood. It's a bit unfortunate, but I suppose there's not much we can do on our end aside from possibly opening an issue in the WPF repository.

Out of curiosity (since we don’t want to disable UI automation), is it possible for us to disable it ourselves externally, or is it something that's handled internally within the controls?

Thanks again for the clarification.

Posted 2 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Sorry, but I'm not entirely clear on what you are trying to disable when you say "disable it oursevles" since you also said you don't want to disable UI automation.  Each AutomationPeer class is what enables UI automation to work, and every control has a default AutomationPeer.  I am not aware of any type of global setting to disable the creation of AutomationPeer classes since they are essential to UI automation and accessibility APIs.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.