I am making an app that involves a lot of animation.
For example:
I got a group of png files(50+) and iterate them with the frame rate of 15fps, to make it looks like an animation.
I have many groups of image files like that. image size: 480x800, with alpha.
my app works basically okay, while I found a lot of GC_FOR_ALLOC in the logcat while playing animation.
my question is that with so many GC_FOR_ALLOC, can I just ignore them, or figured someway to eliminate them? my app also has an minor problem, not sure if related with GC, on some older android devices, the frame rate can not get to even 10fps.
I tried to recycle the bitmap, but it seems only mark that item is available for GC.
I load image this way:
BitmapFactory.Options localOptions = new BitmapFactory.Options();
localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
try {
return BitmapFactory.decodeStream(context.getAssets().open(fileName), null, localOptions);
} catch (IOException e) {
e.printStackTrace();
}
return null;
after load the image, I draw them on SurfaceView, like this:
canvas.drawBitmap(BgImage,rectBG2, rectScreen2, null);
for every frame, I need to draw about 3 images(3 layers). not sure if that has anything to do with GC.
below is an example of those GCs:
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17653K/32583K, paused 29ms, total 29ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17653K/32583K, paused 25ms, total 25ms
E/ttt ( 4993): 64
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 25ms, total 25ms
E/ttt ( 4993): 64
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 26ms, total 26ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 37ms, total 37ms
E/ttt ( 4993): 83
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 37ms, total 38ms
E/ttt ( 4993): 68
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 25ms, total 26ms
E/ttt ( 4993): 53
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 25ms, total 26ms
E/ttt ( 4993): 62
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 27ms, total 27ms
E/ttt ( 4993): 67
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 27ms, total 27ms
E/ttt ( 4993): 67
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 26ms, total 26ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 27ms, total 27ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 26ms, total 26ms
E/ttt ( 4993): 65
currently I am trying a way to load bitmap from JNI, like game engine did, not sure if this is the right way to do it.