Property Grid: Changing the SelectedObject causes memory leak
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the supplied MainWindow/Button_Click reproduction and the XAML PropertyGrid SelectedObject binding. Repeat the 2,000 object changes, force collection as shown, and inspect whether PropertyItem-related objects remain retained; done means repeated changes no longer leave the reported growing instances.
Written by the indexing model from the issue text.
Description
Hello;
I need help; PropertyGrid 4.4.0 in .NET6 WPF
Every time I change the SelectedObject the ManagedMemeory increases. e.g. in the example below I change the SelectedItem 2000x and the objects will never get collected.
What am I doing wrong; Thx.
Managed Memeory after 2000x changes Count Size Inclusive size
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItemCollection 4000 224000 9570840
List<Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem> 4000 240000 5577120
ObservableCollection<Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem> 4000 224000 6313120
Xceed.Wpf.Toolkit.PropertyGrid.ObjectContainerHelper 4000 291312 4223768
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem 2000 3764808 19228568
Xceed.Wpf.Toolkit.PropertyGrid.DescriptorPropertyDefinition 2000 1952000 3007536
public partial class MainWindow : Window, INotifyPropertyChanged
{
public MyModel SelectedItem { get; set; }
public MyModel MyInstance1 { get; set; } = new MyModel();
public MyModel MyInstance2 { get; set; } = new MyModel();
public event PropertyChangedEventHandler? PropertyChanged;
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i < 1000; i++)
{
SelectedItem = MyInstance1;
SelectedItem = MyInstance2;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
public class MyModel : INotifyPropertyChanged
{
public string MyModelString { get; set; } = "testString";
public event PropertyChangedEventHandler? PropertyChanged;
}
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<StackPanel>
<Button Click="Button_Click" Content="ClickMe"/>
<xctk:PropertyGrid SelectedObject="{Binding SelectedItem}"/>
</StackPanel>
</Grid>
</Window>
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 912
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xceedsoftware/wpftoolkit
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
xceedsoftware/wpftoolkit#1808 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
xceedsoftware/wpftoolkit#1807 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
xceedsoftware/wpftoolkit#1806 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
xceedsoftware/wpftoolkit#1804 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
xceedsoftware/wpftoolkit#1802 · 3 comments ·
All issues in xceedsoftware/wpftoolkit
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·