安卓:位图的循环(),它是如何工作的? [英] Android: Bitmap recycle() how does it work?

查看:101
本文介绍了安卓:位图的循环(),它是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说,我已经装在一个位图对象的图像像

Lets say i have loaded an image in a bitmap object like

Bitmap myBitmap = BitmapFactory.decodeFile(myFile);

现在,如果我加载像

myBitmap = BitmapFactory.decodeFile(myFile2);

发生了第一MYBITMAP这是什么让垃圾回收或做我必须加载另一个位图,如之前手工垃圾收集。 myBitmap.recycle()

另外有没有更好的方式来加载大量的图像和另一个循环的方式

Also is there a better way to load large images and display them one after another recycling on the way

推荐答案

第一个位图是不是GC'ed当C中的第二个代$ C $。 GC将在以后无论何时决定这样做。如果你想释放内存尽快与您应该只是第二位图解码之前调用循环()。

The first bitmap is not GC'ed when you decode the second one. GC will do it later whenever it decides. If you want to free memory ASAP you should call recycle() just before decoding the second bitmap.

如果要加载非常大的图像,你应该重新取样它。这里有一个例子<一href="http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966">http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966.

If you want to load really big image you should resample it. Here's an example http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966.

这篇关于安卓:位图的循环(),它是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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