我有测试应用程序:
http://www.mediafire.com/download/y5nxo6esifys4h0/LeakMemLLS.rar
它由 2 页组成:
主页。
ListItems 页面(使用 LongListSelector)。
当我多次进入 ListItems 页面并返回主页时。内存在增加。
有谁知道是什么问题?
谢谢。
我有测试应用程序:
http://www.mediafire.com/download/y5nxo6esifys4h0/LeakMemLLS.rar
它由 2 页组成:
主页。
ListItems 页面(使用 LongListSelector)。
当我多次进入 ListItems 页面并返回主页时。内存在增加。
有谁知道是什么问题?
谢谢。
When you navigate back from PhoneApplicationPage, and then again to it, runtime create a new instance of it. Therefore this memory increase you see. Usually it's okay, since garbage collector will reclaim the unused instances when it will be necessary.
每次到达onNavigateTo()任何页面时都必须清除堆栈,所有页面都保持在堆栈中, GC.Colect()不能删除您的堆栈。
int a = NavigationService.BackStack.Count();
while (a > standerdCount)
{
this.NavigationService.RemoveBackEntry();
a = NavigationService.BackStack.Count();
}
standerdCount是应用程序第一次到达页面时的堆栈计数。
或者,您可以NavigationService.GoBack()在从 ListItem Page 导航到 MainPage 时使用。