locked
XAML page memory issue RRS feed

  • Question

  •  Hi All,

       I am facing serious memory issue in my xaml windows store app. My application will have 8 pages some pages used navigation cachemode & gridview,listview controls. After 10 to 15 mins continuous usage of app(navigating to & from between pages) application consumed more than 300 MB. After that application causing unexpected  behavior( App bar events is not firing, Can't able type in textbox it takes some delay to display the typed characters,Random crash occurs some time).  Is there any memory leak in xaml controls ?

    Anyone knows please kindly help me...

    Thanks


    Dheeraj PK http://dheerajpk.wordpress.com/

    Wednesday, October 23, 2013 6:01 PM

Answers

  • Hi, DheerajDheeraj

    You can refer to the link below to look for memory growth in your app.

    http://msdn.microsoft.com/en-us/magazine/jj721593.aspx

    I suggest you can try these method, may be these can help you:

    1. Adding GC Determinism in your app, the link above explain it and describe how to use it.
    2. Try to use NavigationCacheMode.Enabled instead of NavigationCacheMode. Required. And you can generally subscribe to Application level events (like sized changed, datarequested etc.) and add all event hander in the OnNavigatedTo function and unsubscribe and remove  all event handelr from the OnNavigatingFrom if you need to handle this event on the page level.
    3. When you are navigating forward, you can set NavigationCacheMode to Disabled before you call Frame.Navigate. Then, in OnNavigatedTo() set NavigationCacheMode back to Enabled again. That should make it so that when you navigate forward, caching is disabled. But when you arrive on the new page instance, OnNavigatedTo would enable it again. When you want to navigate back, you wouldn't touch the NavigationCacheMode before calling Frame.GoBack.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    • Edited by Anne Jing Friday, October 25, 2013 8:41 AM edit
    • Marked as answer by Anne Jing Wednesday, October 30, 2013 5:38 AM
    Friday, October 25, 2013 2:15 AM

All replies

  • Hi, DheerajDheeraj

    There are no artificial limits on memory for Metro style apps. But, according to this MSDN Blog, it suggest the memory metrics for app while it is suspended, based on its complexity and general size:

    App   complexity (approx.)

    Total   working set (max)

    Minimal   app (ex. Hello World)

    50-70 MB

    Medium   app (ex. Weather)

    80-100 MB

    Large   app (ex. Photos)

    120-150 MB

    And there are some links you can refer to know how to improve your app performance:

    http://blogs.msdn.com/b/windowsappdev/archive/2012/04/03/how-to-improve-performance-in-your-metro-style-app.aspx

    http://blogs.msdn.com/b/windowsappdev/archive/2012/04/05/tackling-performance-killers-common-performance-problems-with-metro-style-apps.aspx

    Also, there is "Performance best practices for Windows Store app" which can help you:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh750313.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 24, 2013 5:43 AM
  • Thanks for reply.

    I tried another simple application.

    Memory Issue
     
     
    1.      For experiment I created a sample WinRT app. In my app I have a MainPage.xaml. While I am running the same it takes 9 MB Memory. After that I added a    
             Button into the Mainpage. After that suddenly it raises to 15 MB.
     
    2.      If I am adding more pages and controls to my app. the memory is get utilizes more. And it's not coming down.
            imp:  If I am moving out of the page then also memory is not coming down.
       
            I used "this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;" in all my pages constructor.
     
            So after sometime my application get hanged.
     
            Is there any solution for this issue?


    Dheeraj PK http://dheerajpk.wordpress.com/

    Thursday, October 24, 2013 11:23 AM
  • Hi, DheerajDheeraj

    You can refer to the link below to look for memory growth in your app.

    http://msdn.microsoft.com/en-us/magazine/jj721593.aspx

    I suggest you can try these method, may be these can help you:

    1. Adding GC Determinism in your app, the link above explain it and describe how to use it.
    2. Try to use NavigationCacheMode.Enabled instead of NavigationCacheMode. Required. And you can generally subscribe to Application level events (like sized changed, datarequested etc.) and add all event hander in the OnNavigatedTo function and unsubscribe and remove  all event handelr from the OnNavigatingFrom if you need to handle this event on the page level.
    3. When you are navigating forward, you can set NavigationCacheMode to Disabled before you call Frame.Navigate. Then, in OnNavigatedTo() set NavigationCacheMode back to Enabled again. That should make it so that when you navigate forward, caching is disabled. But when you arrive on the new page instance, OnNavigatedTo would enable it again. When you want to navigate back, you wouldn't touch the NavigationCacheMode before calling Frame.GoBack.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    • Edited by Anne Jing Friday, October 25, 2013 8:41 AM edit
    • Marked as answer by Anne Jing Wednesday, October 30, 2013 5:38 AM
    Friday, October 25, 2013 2:15 AM