Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my Android app allocate substantially different amounts of memory on different OS versions?

I have a very simple Android application consisting of a single Activity with some text boxes and a little bit of processing code.

When I install it on a 2.3 device and open it for the first time, it allocates ~2.7MB of memory (according to the Heap update tab in Eclipse DDMS).

On a 3.1 device, it allocates ~6.1MB.

On a 4.0 device, it allocates ~13.8MB.

I've made no code changes between the 3, and these measures were taken upon initial install/opening of the application (so it hasn't had time to do any leaking). It uses no images, and does not specifically have hardware acceleration enabled.

Does anyone know why the footprints might differ so much? I assume it has to do with differences in the OS versions, but I'm wondering if anyone knows what those differences might be.

I have read about the change in Bitmap allocation from 3.0 onward causing apparent increases in allocated memory, but my application doesn't use any images. It only consists of a few EditText fields and TextViews.

like image 508
mWillis Avatar asked Nov 13 '22 09:11

mWillis


1 Answers

Pre-Honeycomb bitmaps were allocated in native heap. Since Android 3.0 (including ICS), the pixel data for bitmaps are allocated in Dalvik heap. The difference between 2.3 and 3.1 might be because of this.

ICS indeed uses memory than 3.1 and I don't know the reason for it.

like image 109
Caner Avatar answered Nov 16 '22 02:11

Caner