Bitmap生成和释放流程

来源:互联网 发布:js数字小数点后两位 编辑:程序博客网 时间:2024/06/08 06:18

      这里写的比较粗糙,只是一些代码的片段,当时比较忙,这是看代码的时候随手做的笔记。看到这篇文章看的人多,现在已经重新写了一下,请参见《BitmapFactory.decodeResource VS BitmapFactory.decodeStream》和《Bitmap的释放流程》,希望对大家有所帮助。


android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)

android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
nativeDecodeStream (BitmapFactory.cpp)
doDecode
decoder->decode
this->onDecode (SKImageDecoder_libpng.cpp)
SkImageDecoder::allocPixelRef
allocator->allocPixelRef(this, ctable)
GraphicsJNI::setJavaPixelRef(env, bitmap, ctable, fReportSizeToVM)
Dalvik_dalvik_system_VMRuntime_trackExternalAllocation


GraphicsJNI::createBitmap(env, bitmap, false, ninePatchChunk);


nativeCreate (Bitmap.java)
Bitmap_creator
GraphicsJNI.setJavaPixelRef
Dalvik_dalvik_system_VMRuntime_trackExternalAllocation (dalvik\vm\native\dalvik_system_VMRuntime.c)
dvmTrackExternalAllocation (dalvik\vm\alloc\HeapSource.c)
externalAllocPossible
doThrowOOME




Bitmap.recycle
nativeRecycle
Bitmap_recycle (Bitmap.cpp)
SkBitmap.freePixels
AndroidPixelRef->unref(); (Graphics.cpp)
SkRefCnt.unref
SkDELETE(this); (delete this)
~AndroidPixelRef
Dalvik_dalvik_system_VMRuntime_trackExternalFree
原创粉丝点击