java - How is a bitmap's memory managed on Android? -


i following this article on android developer, quotes :

on android 2.3.3 (api level 10) , lower, backing pixel data bitmap stored in native memory. separate bitmap itself, stored in dalvik heap. pixel data in native memory not released in predictable manner, potentially causing application briefly exceed memory limits , crash. of android 3.0 (api level 11), pixel data stored on dalvik heap along associated bitmap.

there another article confused me further :

a bitmap thin wrapper around native heap memory area stores pixel data.

i have multiple doubts :

  1. what difference between dalvik heap, native heap , native memory ?
  2. how bitmap different pixel data ? understanding image file (unless it's vector image) called bitmap - compressed. android decompresses/decodes information render pixels on screen. if correct, why need compressed bitmap anymore ?
  3. how class bitmapregiondecoder work ? understanding entire bitmap decoded/decompressed first, , areas out of bound ignored - in memory efficiency not make decoding faster. correct ?
  4. what happens when bitmap recycled ?

when having outofmemoryerror, try code below.

try {     bitmap = bitmap.createbitmap(bm, 0, 0, bm.getwidth(), bm.getheight(), m, true);     return bitmap; } catch (outofmemoryerror e) {     bitmap.recycle();     bitmap = bitmap.createbitmap(bm, 0, 0, bm.getwidth(), bm.getheight(), m, true);     return bitmap; } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -