4

Noticed that when navigating to a page over and over 200+ times with Frame.Navigate(Type) the memory for the app process continues to grow to a huge amount. The page starts to become sluggish once the process reaches 100 MB which is about ~50 clicks.

From what I can tell, the page is instantiated every time it is navigated to (the page constructor is hit). Even though this page is fairly small, the app can grow towards ~1GB of memory.

Obviously the user is not going to navigate to the same page 200 times, but this app is long lived and there are many pages, so I do have some concern about this issue.

Are there any techniques for preventing this kind of memory growth?

O.O
  • 11,077
  • 18
  • 94
  • 182
  • You will have to describe more about what your pages contain. In my opinion, this is a fairly broad subject - here are the things that I have found in my app: [event handlers hanging onto objects](http://stackoverflow.com/questions/1089309/weak-events-in-net), [improper usage of ObserveableCollection](http://neverindoubtnet.blogspot.com/2010/08/observablecollection-datagrid-memory.html), even a [3rd party control leaking memory](https://github.com/Adrotator/AdrotatorV2/issues/53). – chue x Jun 29 '15 at 23:48

1 Answers1

0

Please make sure you've used lots of "Using" statements in your code and also use the Page_Unloaded or OnNavigatedFrom(NavigationEventArgs e) events to clean up all the heavy objects and other resources you're using on your pages.

Or if you can convert your app into MVVM model the page usually cache itself and will consume less memory.

SurenSaluka
  • 1,534
  • 3
  • 18
  • 36