Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Memory Leak in MVVM / HD images (C# WP8)

$
0
0

Hi.

I have an app that shows 50 HD images/photos when the user clicks "show images". The problem is that each time the user gets back to the MainPage and then clicks "show images" again, the ApplicationPeakMemoryUsage keeps increasing until the app terminates itself...


Here's where I'm almost sure the problem is:

        private void LoadXML(string fileName)
        {
            XDocument doc;

            IsolatedStorageFile isstore = IsolatedStorageFile.GetUserStoreForApplication();    
            try
            {
                using (Stream stream = isstore.OpenFile(fileName+".xml", FileMode.Open, FileAccess.Read))
                {
                    doc = XDocument.Load(stream, LoadOptions.None);

                        foreach (XElement el in doc.Root.Elements())
                        {
                            foreach (XElement element in el.Elements().Descendants())
                               this.Items.Add(new DataItemViewModel() { ImageSource = element.Value });
                        }

                    this.IsDataLoaded = true;           
                }
            }
            catch
            {
            }
        }


I've tried everything, from LongListSelector, LongListMultiSelector, 3rd party image galeries templates, App.ViewModel.Items.Clear(), GC.Collect(), DataContext = null, ...

but with no sucess.

Any hints?

Thank You



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>