Skip to content

InputScopeAttribute leaks on TextBox in WPF. #8192

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


Version: .NET 4.5 (may be later)

I repeatedly enter and delete characters in a WPF TextBox.
It leaks a little memory.

I checked with CLRProfiler45.
The leaking object is InputScopeAttribute.
I close the window, but the InputScopeAttribute object count does not decrease.

I found the cause on referencesource.
TextStore is not decrementing the reference count of InputScopeAttribute.

https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Documents/TextStore.cs,2698

2700  attrval.val.data1.Value = Marshal.GetIUnknownForObject(obj);
2784  _preparedattributes.Add(attrval);
  

The TextStore gets the reference count of the InputScopeAttribute with Marshal.GetIUnknownForObject.

 785  _preparedattributes.Clear();
2666  _preparedattributes.Clear();
  

But it’s not releasing the reference count with Marshal.Release.


Original Comments

Feedback Bot on 5/17/2023, 02:09 PM:

(private comment, text removed)

Feedback Bot on 9/5/2023, 10:54 AM:

(private comment, text removed)


Original Solutions

(no solutions)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions