I am decoding multiple MJPEG stream at once, and due to the way the decoding on android devices work, BitmapFactory.decodeByteArray allocates memory everytime it is called, meaning the garbage collection has to work overtime. What I would like to be able to do is control the memory manually, so that the same block can be reused and reduce the number of time the garbage collector is run as it is having a significant impact on performance.
Has anyone had any experience with this?
I am currently just using this call.
newBitmap = BitmapFactory.decodeByteArray(frameBuffer, 0, frameSize);
Any help would be appreciated!
Thanks
BitmapFactory.decodeByteArray() can take an additional BitmapFactory.Options parameter. If you set the inBitmap field to an existing bitmap, it may reuse the bitmap object. This can greatly reduce garbage collections.
For more information, see the "Using an existing bitmap" section of this page: http://developer.android.com/training/displaying-bitmaps/manage-memory.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.