Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
XamGrid memory leak
posted

Hello.

I have a XamGrid with ItemsSource binded on List<>. For example, there are 4 items in collection.

Also, there is a "refresh" button, that creates new List<>

 

For test memory leak I use ObjectTracker from:

http://davybrion.com/blog/2009/08/tracking-dangling-object-references-in-silverlight/ .

I press "refresh" button some times and see how many tracked objects not GCed.

code in "refresh" button:

       public int TrackingObjectsCount
        {
            get { return ObjectTracker.GetAllLiveTrackedObjects().Count(); }
        }

        void btn1_Click(object sender, RoutedEventArgs e)
        {
            Collection = new List<TestClass>
                                                         {
                                                             new TestClass{Name = "name1",Age = 1},
                                                             new TestClass{Name = "name2",Age = 2},
                                                             new TestClass{Name = "name3",Age = 3},
                                                             new TestClass{Name = "name4",Age = 4}
                                                         };


            foreach (var testClass in Collection)
            {
                ObjectTracker.Track(testClass);
            }

            RaisePropertyChanged("TrackingObjectsCount");
        }

As I understand, because List<> creates each time with new items, they should be GCed, but they not.

For example, on first click I have 4 live objects, on second 8 and so on.

It seems that XamGrid still has references on them.

You can see a code example on attached file.

There is an official XamGrid bug?

 

If you have a questions, please ask. I'm not sure in my english :)

 

Test Project zip file:

 

BR,

Alexey Lukyanov