OutOfMemoryException异常当CF.NET创建一个大的位图 [英] OutOfMemoryException When Creating a Large Bitmap in CF.NET

查看:142
本文介绍了OutOfMemoryException异常当CF.NET创建一个大的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我Compact Framework的应用程序创建一个平滑滚动列表通过渲染的所有项目要大位图表面,然后复制该位图偏移位置在屏幕上,这样只有适当的项目展示。旧版本只能使当时在屏幕上应该出现的项目,但这种方法是一个平滑滚动界面太慢了。

My compact framework application creates a smooth-scrolling list by rendering all the items to a large bitmap surface, then copying that bitmap to an offset position on the screen so that only the appropriate items show. Older versions only rendered the items that should appear on screen at the time, but this approach was too slow for a smooth scrolling interface.

这偶尔会生成时最初创建大的位图一个OutOfMemoryException。如果用户执行该装置的一个软复位和重新运行该应用程序,它是能够执行没有问题的产生。

It occasionally generates an OutOfMemoryException when initially creating the large bitmap. If the user performs a soft-reset of the device and runs the application again, it is able to perform the creation without issue.

它看起来并不像这样的位图在程序存储器中产生,因为应用程序使用大约程序存储相同数量的,因为它的新的平滑滚动的方法以前那样。

It doesn't look like this bitmap is being generated in program memory, since the application uses approximately the same amount of program memory as it did before the new smooth-scrolling methods.

有一些方法可以让我prevent此异常?有什么办法,我可以释放我需要的内存(无论是)的异常被抛出过吗?

Is there some way I can prevent this exception? Is there any way I can free up the memory I need (wherever it is) before the exception is thrown?

推荐答案

我建议要回呈现仅部分数据的旧机制,作为完全呈现的数据的大小是明显的问题。为了帮助prevent渲染我想可能问题pre-上面渲染和当前视图下方几行,使他们能够在有限的影响滚动。

I'd suggest going back to the old mechanism of rendering only part of the data, as the size of the fully-rendered data is obviously an issue. To help prevent rendering problems I would probably pre-render a few rows above and below the current view so they can be "scrolled" in with limited impact.

这篇关于OutOfMemoryException异常当CF.NET创建一个大的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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