+ 1

Android - Limited Bitmap memory problem

I have already coded some Android games. But in my current game, I am working with very large images. My problem is, that the notorious OutOfMemoryError keeps crashing the program. For my game is no way around containing a big count of Bitmaps simultaneously. Is there any way, how I can solve this problem?

1st Sep 2017, 8:19 PM
JustAnUser
6 ответов
+ 10
Hmm. Do you need all the bitmaps in memory? If not, have you tried to free the memory before you draw the next bitmap?
1st Sep 2017, 8:50 PM
Tashi N
Tashi N - avatar
+ 9
1st Sep 2017, 8:40 PM
Tashi N
Tashi N - avatar
+ 7
Why do you need to use bmp's? Wouldn't png's be better?
1st Sep 2017, 8:29 PM
Tashi N
Tashi N - avatar
+ 2
@Tashi N Is it possible to draw in Android without Bitmaps? I mean - You create a Bitmap out of a png file to draw it later on a canvas. Isn't it?
1st Sep 2017, 8:34 PM
JustAnUser
+ 1
@Tashi N Yes, I tried it already. It improves the situation, but it does not remove the problem: Two more Bitmaps and there you are: OutOfMemoryError.
1st Sep 2017, 8:46 PM
JustAnUser
+ 1
@Tashi N This is a good idea. I will test it tomorrow ... or The Day After Tomorrow ... Hopefully the application does not get slow, if I permanently recycle and create Bitmaps. Thank you for your detailed help!
1st Sep 2017, 9:00 PM
JustAnUser