C# 具有嵌套自定义控件的Windows Phone 8.1 SL Pivot控件内存泄漏
我发现,如果我有一个数据模板中有自定义控件的pivot,那么每次滑动pivot都会泄漏~2-3mb。即使自定义控件为空,此问题也会重新出现。我的目标是让自定义控件加载一个图像,但是泄漏更严重 如何释放pivot上不再可见的未实现对象的内存 自定义控件的codebehind为空。我已禁用控件上的图像显示,因为我认为在解决第二个问题之前,我还需要解决另一个问题 完整代码示例: 不加载任何图像的内存配置文件(没有足够的点来加载图像) 复制:C# 具有嵌套自定义控件的Windows Phone 8.1 SL Pivot控件内存泄漏,c#,xaml,memory-leaks,win-phone-silverlight-8.1,C#,Xaml,Memory Leaks,Win Phone Silverlight 8.1,我发现,如果我有一个数据模板中有自定义控件的pivot,那么每次滑动pivot都会泄漏~2-3mb。即使自定义控件为空,此问题也会重新出现。我的目标是让自定义控件加载一个图像,但是泄漏更严重 如何释放pivot上不再可见的未实现对象的内存 自定义控件的codebehind为空。我已禁用控件上的图像显示,因为我认为在解决第二个问题之前,我还需要解决另一个问题 完整代码示例: 不加载任何图像的内存配置文件(没有足够的点来加载图像) 复制: 在调试器中加载示例应用程序 加载后,选择“查看配置文件”按
<phone:PhoneApplicationPage
x:Class="PanoramaApp1.Views.ProfilePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:PanoramaApp1.ViewModels"
xmlns:controls="clr-namespace:PanoramaApp1.Controls"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<shell:SystemTray.ProgressIndicator>
<shell:ProgressIndicator IsIndeterminate="True" Text="Loading..." />
</shell:SystemTray.ProgressIndicator>
<phone:PhoneApplicationPage.Resources>
<vm:ProfileCollectionViewModel x:Key="viewModel"/>
<DataTemplate x:Key="HeaderTemplate">
<TextBlock Text="{Binding TargetProfile.ScreenName}"
FontSize="{StaticResource PhoneFontSizeMedium}"/>
</DataTemplate>
<DataTemplate x:Key="ItemTemplate">
<controls:WindowsPhoneControl1 Visibility="Visible"/>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--TitlePanel contains the name of the application and page title-->
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" MaxHeight="80"/>
</Grid.RowDefinitions>
<phone:Pivot
x:Name="ProfilePivot"
Grid.Row="0"
DataContext="{StaticResource viewModel}"
ItemsSource="{Binding Profiles}"
SelectionChanged="ProfilePivot_SelectionChanged"
HeaderTemplate="{StaticResource HeaderTemplate}"
ItemTemplate="{StaticResource ItemTemplate}" />
</Grid>
</phone:PhoneApplicationPage>
WindowsPhoneControl1.xaml
<UserControl x:Class="PanoramaApp1.Controls.WindowsPhoneControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--This make the leak even worse!!
<Image x:Name="Image" Source="{Binding TargetProfile, Converter={StaticResource ProfileBackgroundImageConverter}}" />-->
</Grid>
</UserControl>