1

For Example I am having 2 pages in UWP application. with the names Mainpage and HomePage. Now I am using below statement for navigating to HomePage from MainPage.

Frame.Navigate(typeof(HomePage))

Now I want to dispose objects and memory of my MainPage. How Can we do that in UWP applicaiton.

Please provide your suggestions to solve this issue.

Sagar
  • 371
  • 9
  • 26

1 Answers1

3

You do not, the garbage collector does it for you when appropriate.

Igor Kulman
  • 16,211
  • 10
  • 57
  • 118
  • 4
    It seems like its not doing. We are getting memory leakage problems because of not disposing current page. – Sagar Apr 26 '17 at 16:32
  • Igor is correct! So I'd say that in this case, something in your code is causing the memory leaks! – Pedro Lamas Apr 26 '17 at 17:35
  • @Sagar maybe you set navigation cache mode to enabled or required, so the page is kept in memory. – Igor Kulman Apr 26 '17 at 18:14
  • @IgorKulman Thanks for your suggestion. I have tried navigation cache mode to enabled and required as like you said it's clearing memory but my application is not working as we expected and some times automatically crashing because of adding this line. Any guess why it's behaving like this. – Sagar Apr 27 '17 at 07:52
  • Set it to disabled which might help if the page is only shown once and you don't go back – Jaiganésh Kumaran Oct 14 '20 at 13:02