简体   繁体   English

WP7-性能和内存问题

[英]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 具有1个菜单+ 3个动态(阅读提要)Panaroma项目的MainPage Panaroma页面
  • HistoryPage another Panaroma Page (3panaroma items) with static Textblocks and 2-3 15kb images HistoryPage具有静态文本块和2-3个15kb图像的另一个Panaroma页面(3个panaroma项目)
  • AboutPage Static Pivot (2items) Page with Textblocks and 1 15kb image. AboutPage静态数据透视表 (2个项目)页面,带有文本块和1个15kb图像。

Situation 1: 情况一:

  • When Application loaded it takes 37mb memory. 加载应用程序后,它将占用37mb的内存。

  • Then, I navigate to History page and come back to the main page Memory usage increases to 89mb. 然后,我导航到“历史记录”页面并返回主页,内存使用量增加到89mb。

  • Then I navigate again to history page and come back now it becomes 109mb. 然后,我再次导航到历史记录页面,现在返回到109mb。 Everytime I navigate memory usage incrising. 每当我浏览内存使用量增加时。

Situation 2: 情况2:

  • When Application loaded it takes 37mb memory. 加载应用程序后,它将占用37mb的内存。

  • Then, I navigate to About page and come back to the main page Memory usage increases to 54mb. 然后,我导航到“关于”页面,然后返回主页,内存使用量增加到54mb。

  • Then I navigate to history page and come back now it becomes 94mb. 然后我导航到历史记录页面,现在返回到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 MainPage.xaml.cs中的导航按钮

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

HistoryPage.xaml 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 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. 大胆的猜测(没有看到您的代码),每次刷新主页时都会生成(动态)Panorama项目,从而导致额外的负载。

Basically: 基本上:

  • 1st display of mainpage: 3 dynamic panorama items. 主页的第一显示:3个动态全景项目。
  • 2nd display of mainpage: 6 dynamic panorama items. 主页的第二个显示:6个动态全景项目。
  • 3rd display of mainpage: 9 dynamic panorama items. 主页的第三次显示:9个动态全景项目。
  • ... ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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