views:

869

answers:

3

Hi

I am developing an android app and as I read all around and learned for myself, I cant have a lot of images on the screen at the same time or I will get an exception.

The question is how many images or how many KB in images or how many layouts/images can I have at the same time in the screen.

I know this is not the only thing that has influence on memory, but I am looking for a number so I can plan around it.

Thanks

Daniel


Edit:

I just found this on the android dev site (http://developer.android.com/resources/articles/future-proofing.html)

Technique to Avoid, #3: Going Overboard with Layouts

Due to changes in the View rendering infrastructure, unreasonably deep (more than 10 or so) or broad (more than 30 total) View hierarchies in layouts are now likely to cause crashes. This was always a risk for excessively complex layouts, but you can think of Android 1.5 as being better than 1.1 at exposing this problem. Most developers won't need to worry about this, but if your app has very complicated layouts, you'll need to put it on a diet. You can simplify your layouts using the more advanced layout classes like FrameLayout and TableLayout.

I guess this can be my problem.

When it says 'broad' , is it saying on the last level ?

Thanks

Daniel

+1  A: 

The amount of memory varies from device to device and the amount you have to play with depends on what else the system is doing at the time. Your best bet is to not even come close to running the system out of memory if you can help it. What are you doing that you need that many images on the screen?

CaseyB
+1  A: 

This answer has 2 parts

1) its not how much images the screen has, but being carefull on cleaning everything up when finishing the activity

2) Android dev site (http://developer.android.com/resources/articles/future-proofing.html)

Technique to Avoid, #3: Going Overboard with Layouts

Due to changes in the View rendering infrastructure, unreasonably deep (more than 10 or so) or broad (more than 30 total) View hierarchies in layouts are now likely to cause crashes. This was always a risk for excessively complex layouts, but you can think of Android 1.5 as being better than 1.1 at exposing this problem. Most developers won't need to worry about this, but if your app has very complicated layouts, you'll need to put it on a diet. You can simplify your layouts using the more advanced layout classes like FrameLayout and TableLayout.

Daniel

Daniel Benedykt
A: 

I've run into the same problem at work and I didn't find a solution for it.

The app crashes after calling repeatedly createImage(), thru an OutOfMemoryException. My guess is that it's not caused by an Activity or a Context leak as my app always remains active while experiencing this problem.

I've tried to debug the heap to see if there was anything supicious, but no access is possible to the bitmap memory space (I've tried on a G1 1.6, maybe 1.5). So no idea on what's going on there (any possible solutions to this?).

I'm not quite sure what would be the cause, possible memory leak or memory fragmentation issue?

Help is appreciated!

Thanks.

Guillaume

Guillaume TD