So basically, I have a Vector class in which all bitmaps are stored so that I can have a dynamic array. What I actually do is something like this:
Bitmap bmp = Bitmap.decodeResource(context.getResources(), context.getResources().getIdentifier(imageName, "drawable", "com.example.dynamicbitmap"); vector.add(bmp);
What I would like to ask is that.. if I call vector.remove(value), would it free some space in heap space? In short, would the bitmap be automatically recycled? Or do I have to manually invoke it before removing the bitmap object from the vector?
It will not free up the memory immediately. Obsolete bitmap will be GC’ed whenever GarbageCollector decides to do it. So basically you don’t have to call
recycle(), but you can end up withOutOfMemoryExceptionif you will run out memory.If you want to free up memory ASAP – you need to call
recycle()though