I have an application where I am generating many Bitmap objects. Once I create a bitmap, all the remaining bitmaps will be the same size.
Currently I can I load/create a new bitmap in about 50-80 ms on my phone, which works for what I need. However due to the rapid pace of creating these I am hitting constant GC.
I would like to re-use the same bitmap object, but am not sure how to do this through the sdk.
I did compile libjpeg and load my images through the NDK and re-use my bitmaps, however my loading speed dropped to about 200 ms, which is too slow.
I’ll post code later when I have it in front of me.
Questions:
Is there a way to re-use my bitmap objects to avoid GC?
Is there a faster way to load my images through the NDK? Is it possible to hook in to the way the OS is loading the bitmaps? I know about libjpegTurbo, but I cannot get it to compile currently(another topic for another day).
Any other thoughts on the best way to do this.
Why not use a hashmap to store your bitmaps? Then when you load a bitmap, check to see if its in the hashmap first and if it is you can reuse it. If it is not in the hashmap, save it normally and then insert it into the hashmap.