简体   繁体   English

java Android中的位图循环()

[英]Bitmap recycle() in java Android

Need some help for understanding the recycle() method of the class Bitmap. 需要一些帮助来理解类Bitmap的recycle()方法。

If I have a Bitmap[] named "bmp" for example whats the difference between doing 如果我有一个名为“bmp”的Bitmap [],那么做的区别是什么

Bitmap[i].recycle()

And

Bitmap[i]=null;

Whats the best option? 什么是最好的选择? Should I call both? 我应该同时打电话吗?

Thanks 谢谢

According to this question , bitmap data is stored in native memory rather than in the Dalvik heap. 根据这个问题 ,位图数据存储在本机内存中而不是存储在Dalvik堆中。 You should call recycle() to free the memory the bitmap is stored in once you are finished with it. 完成后,您应该调用recycle()来释放存储位图的内存。 It's good practice to set it to null afterwards, although this is somewhat redundant. 之后将它设置为null是一种很好的做法,尽管这有点多余。

See also the api: http://developer.android.com/reference/android/graphics/Bitmap.html#recycle() 另请参阅api: http//developer.android.com/reference/android/graphics/Bitmap.html#recycle()

我认为你的意思是回收,但回收实际上是从内存中释放对象,而将其设置为null仍然会将其保留在内存中。

Android培训课程“ 有效地显示位图 ”,为理解和处理加载和回收位图提供了一些很好的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM