Very high memory consumption on Nexus 7 with Android Bean hardware

I have an application that is quite memory-heavy - handling large bitmaps. I set up the app using well known techniques for handling such bitmaps (no tutorial links in the answers ...) so that it works fine without any exceptions OutOfMemoryError

, but only on HC and ICS devices, on Jelly Bean same the app has almost 80% memory consumption, resulting in poor user experience, the app lags and slows down.

I have prepared a simple test, I just created the simplest Android application using a template in Eclipse; the app only has one action with a background bitmap (1280 x 800). On a device with Android 3.1 (Asus A500), it highlights:

01-23 12:28:02.402: D/dalvikvm(31706): GC_FOR_ALLOC freed 65K, 4% free 6559K/6787K, paused 17ms
01-23 12:28:02.402: I/dalvikvm-heap(31706): Grow heap (frag case) to 10.355MB for 4096016-byte allocation
01-23 12:28:02.432: D/dalvikvm(31706): GC_CONCURRENT freed 1K, 3% free 10558K/10823K, paused 1ms+2ms

      

On Nexus 7 with JellyBean 4.2.1, it highlights:

01-23 12:13:49.740: D/dalvikvm(23815): GC_FOR_ALLOC freed 84K, 4% free 7464K/7700K, paused 18ms, total 18ms
01-23 12:13:49.750: I/dalvikvm-heap(23815): Grow heap (frag case) to 11.338MB for 4096016-byte allocation
01-23 12:13:49.770: D/dalvikvm(23815): GC_FOR_ALLOC freed 1K, 3% free 11463K/11704K, paused 23ms, total 23ms
01-23 12:13:49.800: D/dalvikvm(23815): GC_CONCURRENT freed <1K, 3% free 11463K/11704K, paused 2ms+2ms, total 23ms
01-23 12:13:49.900: D/dalvikvm(23815): GC_FOR_ALLOC freed <1K, 3% free 11463K/11704K, paused 12ms, total 13ms
01-23 12:13:49.920: I/dalvikvm-heap(23815): Grow heap (frag case) to 18.259MB for 7259056-byte allocation
01-23 12:13:49.940: D/dalvikvm(23815): GC_FOR_ALLOC freed 0K, 2% free 18552K/18796K, paused 16ms, total 16ms
01-23 12:13:49.960: D/dalvikvm(23815): GC_CONCURRENT freed <1K, 2% free 18552K/18796K, paused 3ms+2ms, total 17ms

      

So, I have two questions:

1, why does the application consume so much memory when using only one bitmap in the background of its main activity?

2, why does a device with JellyBean have almost 80% memory consumption when running the same app?

EDIT1:

All devices have the same screen resolution: 1280 x 800 pixels

+3


source to share


1 answer


I am running into the same thing. Unfortunately, I suspect this is because the latest versions of android will use 3D accelerator as much as possible - they will take a copy of your image and feed it to the 3D accelerator when it is then used to render the actual pixels the user sees. This is why you are seeing higher memory consumption.

Unfortunately, there is not much that can be done about this. This higher memory usage results in a significantly smoother user experience (this is a design oil that was introduced in android 4.1). If you have already studied various tutorials such as googles rendered bitmaps efficiently , then all I can suggest is to try including largeHeap in the manifest app element - this is what worked for me.



Also, depending on how the application is working, it may be possible to recycle bitmaps. This DevBytes video from Google explains how.

+1


source







All Articles