如何回收在gridview的适配器位图? [英] How to recycle Bitmaps in gridview adapter?

查看:238
本文介绍了如何回收在gridview的适配器位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图在我的Andr​​oid app.I正在加载图像从server.I网格视图我使用延迟加载。我要回收创建here.How适配器或网格视图做Bitmap.recycle()所有位图。我得到了内存,请帮助我。

I have a Grid View in my android app.I am loading images to the Grid view from server.I am using lazy loading. I have to recycle all bitmaps created here.How to do Bitmap.recycle() in Adapter or Grid view. I am getting out of memory, please help me.

推荐答案

您将需要显示一些code(适配器至少)。如果您收到内存不足的错误,你可能没有被正确执行视图回收,否则有内存泄漏。它也有可能是你只是加载一次太多的大位图,但如果你能在所有的,装载鉴于其更可能是你有内存泄漏。

You will need to show some code (your adapter at a minimum). If you're getting out of memory errors, you probably are not implementing view recycling correctly, or otherwise have a memory leak. Its also possible that you're simply loading too many large bitmaps at once, but if you can load the view at all, its much more likely you have a memory leak.

没有人会能够追踪内存泄漏,而不看一些code。 Bitmap.recycle()是不是一个解决方案,垃圾收集器将工作不够好,没有它,如果你的code的其余部分就可以了。

No one is going to be able to track down a memory leak without looking at some code. Bitmap.recycle() is not a solution, the garbage collector will work well enough without it if the rest of your code is ok.

请参阅: http://www.youtube.com/watch?v=_CruQY55HOk有关管理android系统中存储​​和查找内存泄漏精彩演讲。

See: http://www.youtube.com/watch?v=_CruQY55HOk for a great talk on managing memory in android and finding memory leaks.

相关搜索:的http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html对于如何下载或以其他方式正确异步图像加载到像视图列表中的一个例子。

Also try: http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html for an example of how to download or otherwise correctly asynchronously load images into a list like view.

编辑:还检查了图像加载库我写的,所以你不必担心任何的这样的:的 https://github.com/bumptech/glide

also check out an image loading library I wrote, so you don't need to worry about any of this: https://github.com/bumptech/glide

这篇关于如何回收在gridview的适配器位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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