Reputation: 81
While looking up peer to peer networking with blue tooth, i wanted to change some of the sprites that were made around. what i wanted to change was making dummy menus. As of now there is a start menu and thats it. So i made a selection menu, and 2 dummy menus that would display the help and mutliplayer option later.
I noticed that i was getting some very strange results with these dummy png files. It would only display the dummy file and then crash. After changing around the set up i ran into the error that said the android was low on memory and it crashed. It pointed me to where I was creating a new object. I changed the code and then it ran again. The new problem is that this low memory problem still occurs. I am still new to android development.
Are the .png files I am loading to large and thus it is running low on memory? The 2 new dummy pngs were 400 pixels by 300 pixels. If this is true, was my design so close to the memory limit that anything new would ruin it?
If i am incorrect, what are some tips you have to help fix the memory problems?
Thanks
Upvotes: 0
Views: 310
Reputation: 2260
How big the images are on disk is irrelevant. It's how big they get when you load them into memory. If you are using ARGB_8888, 300x400 will turn into a 500K bitmap. Yes, you need to be much more careful. See, for instance, here: http://davidjhinson.wordpress.com/2010/05/19/scarce-commodities-google-android-memory-and-bitmaps/ and
http://www.rbgrn.net/content/363-releasing-bitmap-memory-when-not-needed
Edit: P.S. Welcome to the world of Android. You have just experienced a painful rite of passage that I call "Bitmap Shock." One day you will look back on this and laugh. :-)
Upvotes: 2