Problem

Memory Leak

Posted 6 years ago by Avatar Aleksander Brzozowski
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.
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;
        }
    }
MyWindowConstructor and treeViewSelectedItemChanged event handle
            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;
        }

MyWindow [XAML]
<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>

Comments (2)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Aleksander,

We have recently fixed an issue where certain items were being rooted in memory. I believe this is what you are seeing. This fix will be in the next maintenance release scheduled for this week.

Actipro Software Support
Posted 6 years ago by Aleksander Brzozowski
fine:-)

Best regards
Information The latest build of this product (2014.1 build 0601) was released 1 month ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.