Windows Phone Memory Leak 90MB - Only Two Static Pages

I created two (as simple as possible) .XAML pages.

StaticPage.xaml

  • Shows memory usage
  • Links to MemoryTest.xaml

MemoryTest.xaml

  • Shows only 10 or so. Text blocks each with text = "This is some kind of text."

PROBLEM

If all you do is move back and forth between pages with a hyperlink and then a hardware submarine, memory usage looks good. but if you keep doing it again and again ... BOTH the current memory usage, and the full memory usage is going up !!!!! all over for 90 MB.

View screenshot here:
enter image description here

SideNotes:

Faster or slower navigation does not matter. You do not have the resources to release, there is nothing to do in the code, because there is nothing there ... Now, if you add more controls (as usual, the application will accelerate). Adding more static text blocks also increases the speed of reaching the limit of 90 MB.

This is bad because I have a photo album page that uses memory that is not freed, but after 5 minutes or decent use, it exceeds 90 MB. I need to try to solve this problem so that it does not pass the test in the market.

Here is the code for each page

StaticPage.xaml

public partial class staticPage : PhoneApplicationPage { public staticPage() { InitializeComponent(); } private void HyperlinkButton_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/TestDir/MemTest.xaml", UriKind.Relative)); txtMem.Text = String.Format("{0} MB Peak\n{1} MB Current", (DeviceStatus.ApplicationPeakMemoryUsage / 1048576).ToString(), (DeviceStatus.ApplicationCurrentMemoryUsage / 1048576).ToString()); } } 

MemoryTest.xaml

 public partial class MemTest : PhoneApplicationPage { public MemTest() { InitializeComponent(); } } 
+4
source share
1 answer
  • Do not worry, checking the memory consumption in the emulator, this is not accurate. Use the device.

  • Do not use premature optimization

  • When you wrote the actual application, profile it.

  • Debug builds consume more memory, and memory usage will decrease after navigation when / if the GC flinches.

  • Do not use GC.Collect() . Just don't do it.

+3
source

Source: https://habr.com/ru/post/1402471/


All Articles