Posted 16 years ago
by Aleksander Brzozowski
Version: 4.5.0470
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
Hello
I`ve noticed memory leak in property grid.
Every time I change "SelectedObject" memory using grows up ( 1-7 MB !!!) (look in windows task manager).
Any ideas?
Best regards
Sample is below.MyWindowConstructor and treeViewSelectedItemChanged event handle
MyWindow [XAML]
I`ve noticed memory leak in property grid.
Every time I change "SelectedObject" memory using grows up ( 1-7 MB !!!) (look in windows task manager).
Any ideas?
Best regards
Sample is below.
class TestObject
{
int a;
decimal b;
string c;
[Category("Something"), DisplayName("Int property")]
public int A
{
set
{
this.a = value;
}
get
{
return this.a;
}
}
[Category("Something"), DisplayName("Decimal property")]
public decimal B
{
set
{
this.b = value;
}
get
{
return this.b;
}
}
[Category("Something"), DisplayName("String property")]
public string C
{
set { this.c = value; }
get { return this.c; }
}
public TestObject(int a, decimal b, string c)
{
this.a = a;
this.b = b;
this.c = c;
}
}
public Window1()
{
InitializeComponent();
List<TestObject> list = new List<TestObject>();
for (int i = 0; i < 10; i++)
{
list.Add(new TestObject(i, (decimal)i*100, "Object " + i.ToString()));
}
treeView1.ItemsSource = list;
treeView1.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(treeView1_SelectedItemChanged);
}
void treeView1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
propertyGrid1.SelectedObject = treeView1.SelectedValue;
}
<Window x:Class="MemLeakPropGrid.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="398" xmlns:propgrid="http://schemas.actiprosoftware.com/winfx/xaml/propgrid">
<Grid>
<propgrid:PropertyGrid Margin="0,0,0,62" Name="propertyGrid1" HorizontalAlignment="Right" Width="159" />
<TreeView Margin="0,0,0,62" Name="treeView1" HorizontalAlignment="Left" Width="143" >
<TreeView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Path=A}" Padding="2,0,0,0" Grid.Column="0" />
<TextBlock Text="{Binding Path=B}" Padding="2,0,0,0" Grid.Column="1" />
<TextBlock Text="{Binding Path=C}" Padding="2,0,0,0" Grid.Column="2" />
</Grid>
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
</Window>