Update native allocation size in Bitmap#recycle()
When Bitmap#recycle() is called, the actual memory allocated for the
pixels is released, however, the native allocation size will not be
updated until after GC when the cleaner is called and the native
object is actually released.
Two NativeAllocationRegistry instances are used to register the native
allocation for each bitmap:
1. One with a no-op free function for updating the native allocation
size of the pixel data only, without actually releasing the native
object that's associated with the bitmap instance.
2. sRegistry is the other static one with a valid freeFunction and a
default (estimated) size to actually release the native object
associated with this bitmap.
mRecycler is the cleaner runner from #1, and is used in Bitmap#recycle()
to release the pixel data, as well as to update the native allocation
size accordingly.
For bitmaps that have `Bitmap#recycle()` called, the first cleaner will
be called in recycle(), the other one after GC.
For bitmaps that don't have `Bitmap#recycle()` called, the two cleaners
will both be called after GC.
Bug: 427760318
Flag: EXEMPT bugfix
Test: local test with verification from debugging code
Change-Id: I7f0ad374da8756116abbb9dfd15bca0816966979
Loading
Please register or sign in to comment