Android 中的位图 [英] Bitmaps in Android
问题描述
我有几个关于位图对象和内存及其一般分类的问题.
I have a few questions regarding Bitmap objects and memory and their general taxonomy.
- 什么是内存位图或本机位图?
- 位图内存与堆内存有何不同?
推荐答案
支持 Bitmap 对象的内存是使用本机代码 (malloc()
) 分配的,而不是 Java new
关键字.这意味着内存由操作系统直接管理,而不是由 Dalvik 管理.
The memory that backs a Bitmap object is allocated using native code (malloc()
), rather than the Java new
keyword. This means that the memory is managed directly by the OS, rather than by Dalvik.
本机堆和 Dalvik 的堆之间唯一真正的区别是 Dalvik 的堆是垃圾收集的,而本机的不是.
The only real difference between the native heap and Dalvik's heap is that Dalvik's heap is garbage collected, and the native one isn't.
不过,出于这些目的,这里没有太大区别.当您的 Bitmap 对象被垃圾回收时,它的析构函数将回收本机堆中的相关内存.
For these purposes though, here's not much difference. When your Bitmap object gets garbage collected, it's destructor will recycle the associated memory in the native heap.
来源:
- http://osdir.com/ml/AndroidDevelopers/2009-03/msg00023.html
- android:platform/frameworks/base/graphics/java/android/graphics/Bitmap.java
- android:platform/frameworks/base/core/jni/android/graphics/Bitmap.cpp
这篇关于Android 中的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!