If I have:
Bitmap bitmap = Bitmap.create(..); // instance a
bitmap = Bitmap.create(...); // instance b
bitmap = null;
bitmap = Bitmap.create(...); // instance c
bitmap.recycle();
bitmap = Bitmap.create(...); // instance d
bitmap.recycle();
bitmap = null;
Once this code is executed, which of the 4 instances are still in memory? I know .recycle() instructs the native code to deallocate all resources to that object, but there's no guarantee of when that happens.
The reason I'm asking, is let's look at the following loop:
Bitmap bitmap = null;
while (true) {
bitmap = Bitmap.create(...);
}
This I assume will eventually crash the app (out of memory)? If so, how should this loop be rewritten? (If I'm using bitmap to animate and display changed state).