开发者

memory leak in window phone 7

I tried to control the memory in our application. But the memory is not the same as when a new application starts.

Example:

In app, I have 2 Pages (MainPage.xaml and Page1.xaml).

Code in MainPage(.Xaml):

<Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>开发者_开发技巧

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="147,223,0,0" Name="button1" VerticalAlignment="Top" Width="160"/>
        </Grid>
    </Grid>

and Page1.xaml :

<Grid x:Name="LayoutRoot" Background="Transparent">
        <Button Content="add" Height="72" HorizontalAlignment="Left" Margin="41,12,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
        <Button Content="remove" Height="72" HorizontalAlignment="Left" Margin="240,12,0,0" Name="button2" VerticalAlignment="Top" Width="160" Click="button2_Click" />
        <ListBox Height="666" HorizontalAlignment="Left" Margin="12,90,0,0" Name="lsbMyList" VerticalAlignment="Top" Width="456" />
    </Grid>

Page1: when I returned from the memory MainPage, my application increased from 1Mb to over 5Mb.

In listbox of Page1, I add an Image to listBox, when I Back Page , I set the image control to null URL and imageControl = null; memory is not reduced

Can anyone point me in the right direction?


See instructions on releasing image memory at http://blogs.msdn.com/b/swick/archive/2011/04/07/image-tips-for-windows-phone-7.aspx

How are you confirming that the memory is from the image and not anything else you're using and possibly not clearing up?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜