我试图控制我们应用程序中的内存。但是内存与新应用程序启动时的内存不同。
例子:
在应用程序中,我有 2 个页面(MainPage.xaml 和 Page1.xaml)。
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>
和 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:当我从内存 MainPage 返回时,我的应用程序从 1Mb 增加到超过 5Mb。
在 Page1 的列表框中,我向 listBox 添加了一个 Image,当我 Back Page 时,我将图像控件设置为 null URL 和 imageControl = null; 内存没有减少
谁能指出我正确的方向?