WP8 Out of Memory error while loading Images

早过忘川 提交于 2019-12-04 03:49:29

问题


I am working on Windows Phone 8 app.

I am working on Coverflow feature, i am trying to load 600 items but it always shows Out of Memory Error

Code:

<DataTemplate x:Key="DataTemplate1">
            <Grid VerticalAlignment="Center" HorizontalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0" Height="400" Width="400" CornerRadius="30,30,30,30">
                    <Border.Background>
                        <ImageBrush ImageSource="Images/sample.png" />
                    </Border.Background>
                </Border>
                <Grid Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top">
                    <TextBlock HorizontalAlignment="Center" 
                               VerticalAlignment="Center"
                               Margin="5,20,5,5"
                               Foreground="#000000"
                               Text="{Binding Title}"/>
                </Grid>
                <Grid Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Bottom">
                <TextBlock HorizontalAlignment="Center" 
                               VerticalAlignment="Center"
                               Margin="5,5,5,20"
                               Foreground="#000000"
                               Text="{Binding SubTitle}"/>
                </Grid>
            </Grid>
        </DataTemplate>

I have tried checking why its happening so,because each time it loads image with the below code

<Border Grid.Row="0" Height="400" Width="400" CornerRadius="30,30,30,30">
                        <Border.Background>
                            <ImageBrush ImageSource="Images/sample.png" />
                        </Border.Background>
                    </Border>

I tried removing Width and Height and it works but i want the image to bigger.

How can i fix this ?


回答1:


Here it's been discussed in detail. What you'll need to do is use Memory Profiling and periodically check which the memory Heap to see what's allocated when it shouldn't be.

How to debug running out of memory on Windows Phone



来源:https://stackoverflow.com/questions/24157246/wp8-out-of-memory-error-while-loading-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!