2013-03-28 2 views
0

ScrollViewer에서 메모리 캐시를 적게 사용하도록 전화 앱에서 속성이나 설정을 지정하는 방법을 알고있는 사용자가 있는지 궁금합니다. 나는 현재 화면에 이미지를 표시하는 앱을 가지고 있으며, 화면 가까이 있거나 화면을 가로 지르는 이미지 만 볼 수있게 해주는 알고리즘을 사용해도 많은 경우 확대 될 때 가끔씩 메모리 부족 현상이 발생합니다. 주변의 이미지.Windows Phone 8에서 ScrollViewer의 메모리 사용

예를 들어, 아래의 XAML은 300 개 중 125MB를 먹어 버릴 것입니다. 이것은 단지 빈 흰색 캔버스에만 해당됩니다.

<phone:PhoneApplicationPage 
x:Class="DemoScroller.MainPage" 
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" 
mc:Ignorable="d" 
FontFamily="{StaticResource PhoneFontFamilyNormal}" 
FontSize="{StaticResource PhoneFontSizeNormal}" 
Foreground="{StaticResource PhoneForegroundBrush}" 
SupportedOrientations="Portrait" Orientation="Portrait" 
shell:SystemTray.IsVisible="True"> 

<!--LayoutRoot is the root grid where all page content is placed--> 
<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 Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/> 
     <TextBlock 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"> 
     <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> 
      <Canvas Width="2000" Height="8000"> 
       <Canvas Width="990" Height="1990" Background="White"/> 
       <Canvas Width="990" Height="1990" Canvas.Left="1010" Background="White"/> 
       <Canvas Width="990" Height="1990" Canvas.Top="2000" Background="White"/> 
       <Canvas Width="990" Height="1990" Canvas.Left="1010" Canvas.Top="2000" Background="White"/> 
       <Canvas Width="990" Height="1990" Canvas.Top="4000" Background="White"/> 
       <Canvas Width="990" Height="1990" Canvas.Left="1010" Canvas.Top="4000" Background="White"/> 
      </Canvas> 
     </ScrollViewer> 
    </Grid> 
</Grid> 

</phone:PhoneApplicationPage> 

내 응용 프로그램에서 이미지가 제대로 정렬되어 있지 않기 때문에 목록 상자 나 이와 비슷한 것을 사용할 수 없습니다.

제안 사항? 감사합니다. Tomas

답변

0

이미지를 보이지 않게 만드는 것은 많은 양의 메모리가 소요되는 압축되지 않은 형식으로 디코딩되는 것을 막지 않으며, 특히 크기가 큰 경우에는 더욱 그렇습니다.

이미지가 보이지 않을 때 이미지를 완전히 언로드하는보다 효율적인 가상화 방법이 필요합니다. 그것이 LongListSelector가 줄 수있는 것입니다. ScrollViewer는이 작업을 수행하지 않습니다.

+0

가시성을 축소로 설정 한 경우 이미지가 차지하는 경우에도 실제로 표시 할 때 ScrollViewer에서 먹는 것과 비교하면 땅콩입니다. 비록 내가 대체하고 빈 사각형으로 내 애플 리케이션의 모든 이미지를 버려진, 그것은 여전히 ​​메모리가 정말 빨리 실행됩니다. – Tomas

관련 문제