加载图像时出现 WP8 内存不足错误 [英] WP8 Out of Memory error while loading Images

查看:24
本文介绍了加载图像时出现 WP8 内存不足错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Windows Phone 8 应用.

I am working on Windows Phone 8 app.

我正在研究 Coverflow 功能,我正在尝试加载 600 个项目,但它总是显示 内存不足错误

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

代码:

<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>

我尝试删除 WidthHeight 并且它可以工作,但我希望图像更大.

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

我该如何解决这个问题?

How can i fix this ?

推荐答案

这里已经详细讨论过了.您需要做的是使用内存分析并定期检查哪些内存堆以查看在不应该分配的情况下分配了什么.

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.

如何在 Windows 上调试内存不足电话

这篇关于加载图像时出现 WP8 内存不足错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆