出的Andr​​oid内存prevention [英] Android out of memory prevention

查看:140
本文介绍了出的Andr​​oid内存prevention的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表,显示下载的从网上飞缩略图(小图)。 在某些时候,这个过程耗尽内存。 我怎么能告诉大家,可用内存约为地跑了出去,这样我就可以停止下载更多的图像?

I have a list that shows thumbnails (small images) downloaded on the fly from the web. At some point, the process runs out of memory. How can I tell that the free memory is about to run off, so I can stop downloading more images?

我想知道它提前,以免是对内存不足的边缘。

I would like to know it in advance in order not to be on the edge of out of memory.

请注意: 这不是一个内存泄漏,只是很多下载的位图。

Note: It is not a memory leak, just lots of downloaded bitmaps.

感谢。

推荐答案

我用SoftReference来保存位图对象。这份名单只需要在当前可见的图像。因此,我从来不需要担心空间用完。

I use SoftReference to hold the bitmap objects. The list only needs the current visible images. Thus, I never need to worry about running out of space.

减号是,当我看到的图像,向下滚动(导致一些SoftReferences清除位图),然后再次回滚到同一个地方 - 图像得到重新下载:(

The minus is that when I see the images, scroll down (causing some SoftReferences to clear the Bitmaps), then scroll back again to the same place - the images get downloaded again :(

另外,SoftReferences得到清除非常快。我希望他们能够保存内部位长。

Also, the SoftReferences get cleared very fast. I would expect them to save the inner bitmap longer.

这篇关于出的Andr​​oid内存prevention的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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