android - Memory used by pushing a lot of pages on Xamarin.Forms' NavigationPage -


i have xamarin.forms navigationpage , noticed after pushing quite lot of pages (say 20), app starts being laggy , might freeze @ point. i'm guessing must using lot of memory (i should check in android's monitoring tools thought it).

is there way can provide history functionality (so, user can press go reading before) doesn't eat memory? know it's possible because it's done in other apps.

for solutions multiple pages , large navigation stack use pagesfactory:

public static class pagesfactory {     static readonly dictionary<type, page> pages = new dictionary<type, page>();      static navigationpage navigation;     public static navigationpage getnavigation()     {         if (navigation == null)         {             navigation = new navigationpage(pagesfactory.getpage<views.mainmenuview>());         }         return navigation;     }      public static t getpage<t>(bool cachepages = true) t : page     {         type pagetype = typeof(t);          if (cachepages)         {             if (!pages.containskey(pagetype))             {                 page page = (page)activator.createinstance(pagetype);                 pages.add(pagetype, page);             }              return pages[pagetype] t;         }         else         {             return activator.createinstance(pagetype) t;         }     }      public static async task pushasync<t>() t : page     {         await getnavigation().pushasync(getpage<t>());     }      public static async task popasync()     {         await getnavigation().popasync();     }      public static async task poptorootasync()     {         await getnavigation().poptorootasync();     }      public static async task popthenpushasync<t>() t : page     {         await getnavigation().popasync();         await getnavigation().pushasync(getpage<t>());     } } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -