1

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?

trincot
  • 317,000
  • 35
  • 244
  • 286
dabaerju
  • 103
  • 1
  • 13
  • 1
    side note: http://stackoverflow.com/questions/1386275/why-is-java-vector-class-considered-obsolete-or-deprecated – Matt Wolfe Feb 07 '13 at 05:07

1 Answers1

1

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 with OutOfMemoryException if you will run out memory.

If you want to free up memory ASAP - you need to call recycle() though

Pavel Dudka
  • 20,754
  • 7
  • 70
  • 83