简体   繁体   中英

WP7 - Performance and Memory issue

I have an application and having memory issues. Everytime I navigate between pages memory usage is increasing.

My Application includes three page:

  • MainPage Panaroma page with 1 menu + 3 dynamic (reading feeds) panaroma items
  • HistoryPage another Panaroma Page (3panaroma items) with static Textblocks and 2-3 15kb images
  • AboutPage Static Pivot (2items) Page with Textblocks and 1 15kb image.

Situation 1:

  • When Application loaded it takes 37mb memory.

  • Then, I navigate to History page and come back to the main page Memory usage increases to 89mb.

  • Then I navigate again to history page and come back now it becomes 109mb. Everytime I navigate memory usage incrising.

Situation 2:

  • When Application loaded it takes 37mb memory.

  • Then, I navigate to About page and come back to the main page Memory usage increases to 54mb.

  • Then I navigate to history page and come back now it becomes 94mb.

What are the causes for this problem? Those contents are static texts and I don't use any Isolated storage, tombstoning or anything. How can I make it to remove cache when the user navigates from the page.

Thank you inadvance. Please keep in mind and excuse me I am really noob at coding stuffs like that.

Navigation button in MainPage.xaml.cs

private void Button_Click(object sender, EventArgs e)
{
    NavigationService.Navigate(new Uri("/HistoryPage.xaml", UriKind.Relative));
}

HistoryPage.xaml

        <controls:Panorama.Background>
            <ImageBrush Stretch="Fill" ImageSource="backgrounds/PanoramaBackground.jpg"  />
        </controls:Panorama.Background>

        <!--Panorama item one-->
        <controls:PanoramaItem CacheMode="BitmapCache">
            <ScrollViewer x:Name="hede" Margin="12,0,12,0" Grid.Row="1" Width="432" >
                <StackPanel Width="432">
                    <Image Height="220" Name="image1" HorizontalAlignment="Left" Stretch="Fill" Source="images/logo.png" Width="172" Margin="0,30,0,0" />
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
    </StackPanel>
            </ScrollViewer>
        </controls:PanoramaItem>

        <!--Panorama item two-->
        <controls:PanoramaItem Header="history" CacheMode="BitmapCache">
            <ScrollViewer>
                <StackPanel>
                    <Image x:Name="tarih" Source="images/history.jpg" Stretch="Fill" Width="380" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
    </StackPanel>
            </ScrollViewer>
        </controls:PanoramaItem>

        <!--Panorama item three-->
        <controls:PanoramaItem Header="achievements" CacheMode="BitmapCache">
            <ScrollViewer>
                <StackPanel>
                    <TextBlock ....
    </StackPanel>
            </ScrollViewer>
        </controls:PanoramaItem>

        <!--Panorama item three-->
        <controls:PanoramaItem Header="contact" CacheMode="BitmapCache">
            <StackPanel>
                <my:Map x:Name="stad" Grid.Row="1"
                        CredentialsProvider=.....
                        LogoVisibility="Collapsed" ScaleVisibility="Visible"
                        Center=..... ZoomLevel="15"
                        CopyrightVisibility="Collapsed" ZoomBarVisibility="Visible" Width="380" HorizontalAlignment="Center">
                    <my:Pushpin Location="....." Content="....."></my:Pushpin>
                </my:Map>
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
                    <TextBlock ....
    </StackPanel>
        </controls:PanoramaItem>
    </controls:Panorama>
</Grid>

HistoryPage.xaml.cs

public partial class HistoryPage: PhoneApplicationPage
{
    public HistoryPage()
    {
        InitializeComponent();
    }
}

Wild guess (without seeing your code), you're generating the (dynamic) Panorama Items every time you refresh the main page, causing the extra load.

Basically:

  • 1st display of mainpage: 3 dynamic panorama items.
  • 2nd display of mainpage: 6 dynamic panorama items.
  • 3rd display of mainpage: 9 dynamic panorama items.
  • ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM