After looking at the information Romain Guy posted on the stackoverflow thread, I decided to do a bit more playing with the various loading options. The result shows that forcing the images to be loaded as RGB_565 does reduce the memory in Android 2.3, however it still uses more than 2.2. In my example app, Android 2.3 now uses 10MB vs Android 2.2 using 3MB. Further, I tried to force 32-bit by using ARGB_8888. In this case, Android 2.3 uses 17MB, but Android 2.2 continues to only use 3MB. The updated sample can be found here: http://dl.dropbox.com/u/21709517/MemoryUsageExample2.zip
What is the cause for these differences? Is there more that needs to be done to get the memory usage closer to Android 2.2? Also, is there a way to force images created via xml layouts into a particular format? Can this be set application-wide? Thanks. On Feb 22, 6:00 pm, haplo13 <[email protected]> wrote: > An explanation was given > here:http://stackoverflow.com/questions/5084983/memory-usage-between-andro... > > On Feb 21, 5:21 pm, haplo13 <[email protected]> wrote: > > > > > > > > > Hello, > > I am developing an app that contains many images. I have noticed that > > thememoryusage of my app is quite a bit higher in Android2.3than > > in Android 2.2 - ultimately resulting in OutOfMemory errors while > > loading bitmaps. In researching this, I logged the result of > > Debug.getNativeHeapAllocatedSize() in the onResume of the first > > activity. In Android 2.2, this outputs 5MB. In Android2.3, this > > outputs 17MB. > > > I created a sample application to try to further narrow this down. > > The sample app has 2 activities: the first has a small image and a > > button to launch the second activity; the second activity has several > > large images in a ScrollView. You can download the sample > > here:http://dl.dropbox.com/u/21709517/MemoryUsageExample.zip > > When running this sample, Debug.getNativeHeapAllocatedSize() reports > > 3MB allocated after starting the first activity in both 2.2 and2.3. > > After launching the second activity, Android 2.2 still reports 3MB > > allocated while Android2.3reports 17MB allocated. Running "adb > > shell dumpsys meminfo test.example" shows the same types of results. > > > Why is there such a dramatic difference between Android 2.2 and2.3? > > And more importantly, what should I be doing differently to prevent > > using so muchmemoryon Android2.3? > > > Jeff -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

