Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.OutOfMemoryError: bitmap size exceeds VM budget - android - how many images?

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

like image 902
Daniel Benedykt Avatar asked Dec 23 '22 07:12

Daniel Benedykt


1 Answers

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) (Future-Proofing Your App)

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

like image 174
Daniel Benedykt Avatar answered Jan 17 '23 05:01

Daniel Benedykt