InputScopeAttribute leaks on TextBox in WPF.
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/InputScopeAttribute-leaks-on-TextBox-in-/10365684)._
---
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](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)
Contributor guide
Assessment
This issue has not been assessed yet.