Android 2.3.x OutOfMemory

36 views
Skip to first unread message

Oleg Dmytriienko

unread,
Jun 11, 2012, 5:10:13 AM6/11/12
to PlayN
Hi,
In our app we have a lot of images. When they needed we get them in
such way: PlayN.assets().getImage("imageURL");
In android 2.3 there is limit for 24mb of bitmap resources. So, while
showing images on Screen2(let`s say Game) i must hide (unload) images
from Screen1(lets say Intro).
I have reference to image from Screen1 and i can call clear() method:
CanvaseImage referenceToImage - i need to unload,
referenceToImage.canvas().clear();
BUT, - this way do not unload image from android memory in 2.3.x -
( http://stackoverflow.com/questions/3823799/android-bitmap-recycle-how-does-it-work
this post tell that i should call recycle() on bitmap, since bitmaps
are stored in non-management memory and cant be shrinked from there by
GC.)
and i have such stackTrace for android if images from Screen1 are not
unloaded from memory:
06-11 09:16:45.197: E/AndroidRuntime(23621): FATAL EXCEPTION: GLThread
10
06-11 09:16:45.197: E/AndroidRuntime(23621):
java.lang.OutOfMemoryError: bitmap size exceeds VM budget(Heap
Size=9479KB, Allocated=6032KB, Bitmap Size=23347KB)
06-11 09:16:45.197: E/AndroidRuntime(23621): at
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
06-11 09:16:45.197: E/AndroidRuntime(23621): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:694)
06-11 09:16:45.197: E/AndroidRuntime(23621): at
playn.android.AndroidAssets.decodeBitmap(AndroidAssets.java:158)
06-11 09:16:45.197: E/AndroidRuntime(23621): at
playn.android.AndroidAssets.doGetImage(AndroidAssets.java:79)
06-11 09:16:45.197: E/AndroidRuntime(23621): at
playn.core.AbstractAssets.getImage(AbstractAssets.java:39)

Is there some way to call playN `s magic for recycling bitmaps in
Android 2.3.x memory model?
Reply all
Reply to author
Forward
0 new messages