I have a view which displays a small bitmap, and this is used in many places in my application (especially list views). I'm currently loading this bitmap each time an instance of that view is created using BitmapFactory.decodeResource(resource, id)
. I realized that I can improve performance by loading that bitmap once into a static variable (so that all instances of the view reuse it) and that did indeed save about 2-4 ms per view instance. My question, does using a static variable in this way cause any type of memory leak in Android? I'm worried because I haven't found any other example that uses a static variable to store a bitmap like this.
Follow up question: How to keep a Bitmap in memory
Keeping bitmap objects as static may cause potential memory leaks, see official documents at http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With