Bitmap
- 在Android中,Bitmap是一个非常特殊的类。在内存存储形式也多次被修改。
- 这个问题在官方文档已有定论。
英文摘抄
- On Android 2.3.3 (API level 10) and lower, the backing pixel data for a bitmap is stored in native memory. It is separate from the bitmap itself, which is stored in the Dalvik heap. The pixel data in native memory is not released in a predictable manner, potentially causing an application to briefly exceed its memory limits and crash. From Android 3.0 (API level 11) through Android 7.1 (API level 25), the pixel data is stored on the Dalvik heap along with the associated bitmap. In Android 8.0 (API level 26), and higher, the bitmap pixel data is stored in the native heap.
中文大意
- Android 2.3.3及更低版本,像素点数据(Pixel data)存储在原生内存(Native Memory),但Bitmap对象则存储在Dalvik Heap.这可能导致存在原生内存(Native Memory)的像素点数据(Pixel data)不被正确释放,进而导致应用发生奔溃(Crash)。
- 在Android 3.0(API level 11) ~ Android 7.1(API level 25)中无论是Bitmap对象还是像素点数据(Pixel Data),都统一存储在Dalvik Heap。
- 然而从Android 8.0(API level 26) 开始,截至到2018年3月的版本,素点数据(Pixel Data)被存储到Native Heap。