问题
I have a problem with 90mb peak memory limit issue.
For example: I create 1 Panorama Application(with default content) and add 3 PivotPages or 6 Portrait Page(Page A and Page B.. with blank content). Each time I navigate and go back between these pages the memory usage is going higher and higher. At the end, It passes the 90mb limit.
I use buttons to navigate like this:
private void btn1_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/PageA.xaml", UriKind.Relative));
}
Do I miss something important while navigating between pages? While searching for a solution I heard about garbage collector? How can I use it or do I need to?
I couldn't find an answer for that; I found this similar topic: http://forums.create.msdn.com/forums/p/76007/466968.aspx but there isn't a final solution.
Note: I am using Coding4fun toolkit to measure memory usage.
Edit: I created a sample panorama application with some pivot pages (1 with content).
http://i54.tinypic.com/zfip.jpg
At start, application opened with 30mb. After I navigate to the same pivot page a couple of times, Peakmemory started to increase little by little and stoped at 47mb. Is this normal? Maybe, I didn't understand the dynamics of this application building stuff. But it doesn't make sense if it keeps increasing the ram usage and makes application crush after some use.
回答1:
Somethign is stopping your pages from being unloaded when you navigate away from them. You probably have a resource leak somewhere but without seeing your code we will be very unlikely to be able to help more.
You shouldn't need to worry about garbage collection.
来源:https://stackoverflow.com/questions/6944918/wp7-xaml-pages-and-peak-memory-problem