为什么我永远不会使用 BitmapFactory 的 inPurgeable 选项? [英] Why would I ever NOT use BitmapFactory's inPurgeable option?
问题描述
Android 的 BitmapFactory.Options.inPurgeable
已在各种地方被推荐作为一种方式避免 Android 2.x 及更早版本中的 OutOfMemory 异常(Android 3.1 修复此问题).
Android's BitmapFactory.Options.inPurgeable
has been recommended in various places as a way to avoid OutOfMemory exceptions in Android 2.x and earlier (Android 3.1 fixes this).
如果 inPurgeable
这么棒,我为什么不想使用它?文档 似乎很轻有关此选项正在执行的操作的详细信息:
If inPurgeable
is so great, why would I ever NOT want to use it? The documentation seems very light on details about what this option is doing:
如果设置为 true,则生成的位图将分配其像素,以便在系统需要回收内存时将其清除.在这种情况下,当需要再次访问像素时(例如绘制位图,调用 getPixels()),它们将被自动重新解码
If this is set to true, then the resulting bitmap will allocate its pixels such that they can be purged if the system needs to reclaim memory. In that instance, when the pixels need to be accessed again (e.g. the bitmap is drawn, getPixels() is called), they will be automatically re-decoded
看起来很棒.有什么收获?
Seems great. What's the catch?
推荐答案
文档 随后更新了附加信息以解决您的原始问题.
The documentation has subsequently been updated with additional information which addresses your original question.
总结:不再推荐使用此标志.
Summary: use of this flag is no longer recommended.
这篇关于为什么我永远不会使用 BitmapFactory 的 inPurgeable 选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!