microsoft / microsoft/microsoft-ui-xaml

Regression when targeting .NET10 | Memory Leak

Open
#10,981 3 comments 1 reaction 0 assignees View on GitHub
area-Binding bug team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Memory leak observed when targeting moving from targeting .NET8 -> .NET10

### **Project info**
```
net10.0-windows10.0.22621.0


```

Image

### Information

Image

Memory Profiler points to leak in `List`

Application consists of multiple pages bound with x:bind/binding to various view models.
View models implement a modified version of the `ObservableObjectClass` to allow for updates from background threads.

ViewModel Configuration
```csharp
namespace Observability.Common
{

///
/// Extension of the observable objects class,
/// Allows other threads to trigger binding updates
///
public partial class MoreObservableObject : ObservableObject
{

private static DispatcherQueue Queue { get; set; }
public static void BindGUIThread(DispatcherQueue queue)
{
Queue = queue;
}
public static void Update(Action action)
{
if (Queue == null)
{
action();
return;
}
Queue.TryEnqueue(() => action());
}
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
Update(() => base.OnPropertyChanged(e));
}
}

public class MoreObservableCollection : ObservableCollection
{
public new void Add(T item)
{
MoreObservableObject.Update(() => base.Add(item));
}

public new void Clear()
{
MoreObservableObject.Update(() => base.Clear());
}

public new void RemoveAt(int index)
{
MoreObservableObject.Update(() => {
if (base.Count > index) base.RemoveAt(index);
});
}

}
}

```

### Why is this important?

.NET 10 Support is preferred for long term application viability

### Steps to reproduce the bug

1. Create a WinUI3 Project targeting .NET10
2. Implement a MVVM page using the `MoreObservableObject` class defined above
3. x:Bind to ViewModel state using various strings and doubles
4. Update ViewModel from System.Threading.Timer thread at 10-20Hz

### Actual behavior

Memory usage balloons, calls to` GC.Collect() `do little to nothing.

### Expected behavior

Flat memory usage, in line with .net8 values

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.8.3: 1.8.251106002

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

The report provides no repository file or test; it includes the MoreObservableObject and MoreObservableCollection snippets as the application-side entry point. First reproduce the WinUI 3 project on .NET 8 and .NET 10 while profiling updates from a System.Threading.Timer thread. Done means the leak is isolated to a specific framework or usage path and memory behavior is verified against the .NET 8 baseline.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.