jerrytouille
jerrytouille

Reputation: 1238

Android - do Bitmaps automatically get recycled when an activity finish()?

Do Bitmaps automatically get recycled when an activity finish()?

Or do we have to call recycle() the bitmaps in onDestroy()?

Upvotes: 3

Views: 1158

Answers (3)

minhaz
minhaz

Reputation: 4233

On Pre-honeycomb device

  • Bitmap Object reference allocated on Dalvik Heap
  • Pixel information stored on Native layer
  • recycle() or finalizer() needed to restore memory

On Post honeycomb its standard like any java object

Upvotes: 0

Blackbelt
Blackbelt

Reputation: 157457

In the Pre Android 3.0 you need to recycle it, because the bitmap is stored in the native heap.

Upvotes: 4

Budius
Budius

Reputation: 39846

as long as you're not referencing them by any still alive object: they get garbage collected by the GC without any need to further interaction.

Upvotes: 2

Related Questions