Android的 - 如何避免内存过载使用位图? [英] Android - how to avoid memory over load using bitmaps?

查看:249
本文介绍了Android的 - 如何避免内存过载使用位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序正在使用位图和用户每次走到哪里它显示的图像也停止工作,第二次的具体活动。

My application is using bitmaps and every time the user come to the specific activity where it shows an image the second time it stops working.

Bitmap bm = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+"//Pics/"Image.jpg");

我一直使用的东西试过像...

I have tried using things like...

BitmapFactory.Options options = new BitmapFactory.Options();
     options.inTempStorage = new byte[16*1024];

不知道该怎么设置它。但是,这并不帮助。一旦用户离开这个活动是不是有一种方法来清除位图等?谢谢

Not sure what to set it too. But this doesnt help. Once the user leaves this activity is there not a way to clear the bitmap etc? thanks

推荐答案

呼叫<一href="http://developer.android.com/reference/android/graphics/Bitmap.html#recycle%28%29">Bitmap.recycle()当您使用位图来释放内存完成。

Call Bitmap.recycle() when you are done using the Bitmap to free the memory.

这篇关于Android的 - 如何避免内存过载使用位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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