Re: [android-developers] Re: OOM with heap enough
> > Did you check with MAT? Also you may try to verify this theory by > forcing process termination with System.exit. > > I've doing that since half hundred of versions ago, more or less, so I am > pretty sure about it. > No you don't only you only kill on explicte exit (probably in onBackPressed) not in onDestroy, and as I suspected you leak as hell (like 10MB) on activity restarts (I crashed your game with OOM on SGS2 with 128MB heap and on N7 with 256MB heap): 11-23 19:30:27.673: D/dalvikvm(6289): GC_BEFORE_OOM freed 24K, 2% free 12K/129735K, paused 54ms 11-23 19:30:27.673: E/dalvikvm-heap(6289): Out of memory on a 1536016-byte allocation. 11-23 19:30:27.673: I/dalvikvm(6289): "main" prio=5 tid=1 RUNNABLE 11-23 19:30:27.673: I/dalvikvm(6289): | group="main" sCount=0 dsCount=0 obj=0x40c80460 self=0x12988 11-23 19:30:27.673: I/dalvikvm(6289): | sysTid=6289 nice=0 sched=0/0 cgrp=default handle=1074959656 11-23 19:30:27.673: I/dalvikvm(6289): | schedstat=( 6635628723 11025881606 23463 ) utm=527 stm=136 core=1 11-23 19:30:27.673: I/dalvikvm(6289): at android.graphics.Bitmap.nativeCreate(Native Method) 11-23 19:30:27.678: I/dalvikvm(6289): at android.graphics.Bitmap.createBitmap(Bitmap.java:605) 11-23 19:30:27.678: I/dalvikvm(6289): at android.graphics.Bitmap.createBitmap(Bitmap.java:585) 11-23 19:30:27.678: I/dalvikvm(6289): at com.badlogic.androidgames.framework.impl.AndroidGame.onCreate(AndroidGame.java:182) 11-23 19:30:27.678: I/dalvikvm(6289): at com.marzoa.ruletafree.RuletaAfortunadaGame.onCreate(RuletaAfortunadaGame.java:19) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.Activity.performCreate(Activity.java:4470) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.ActivityThread.access$600(ActivityThread.java:127) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158) 11-23 19:30:27.678: I/dalvikvm(6289): at android.os.Handler.dispatchMessage(Handler.java:99) 11-23 19:30:27.678: I/dalvikvm(6289): at android.os.Looper.loop(Looper.java:137) 11-23 19:30:27.678: I/dalvikvm(6289): at android.app.ActivityThread.main(ActivityThread.java:4511) 11-23 19:30:27.678: I/dalvikvm(6289): at java.lang.reflect.Method.invokeNative(Native Method) 11-23 19:30:27.678: I/dalvikvm(6289): at java.lang.reflect.Method.invoke(Method.java:511) 11-23 19:30:27.678: I/dalvikvm(6289): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980) 11-23 19:30:27.678: I/dalvikvm(6289): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747) 11-23 19:30:27.678: I/dalvikvm(6289): at dalvik.system.NativeStart.main(Native Method) -- Regards, Bart -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
On 11/23/2012 01:19 PM, a1 wrote: W dniu piątek, 23 listopada 2012 12:31:22 UTC+1 użytkownik Fran napisał: On 11/23/2012 10:30 AM, a1 wrote: As told to Mark, I do not think so: the game is just starting, loading the first Screen at all. Really? Well, that's what I can see on that stack trace. But you don't know if this is first run hence you cannot make assumption about process heap state (moreover other data suggest that this is not the case). Data suggest quite the contrary: I think that data may suggest a wide number of different things. If the data is valid (heap size and allocation size) this means that at least at some point your process allocated around 48MB total (if you check android heap management sources you will notice that heap grow algorithm do not excessively over-allocate) and when OOM occurs you still have 33MB allocated. All of above suggest a lot of allocation. Well, as told this may suggest a wide number of different things, for example as you implicitly noted there may be a problem with the report itself and the data may be not reliable, another option is that there may be a bug in the heap management of those devices causing the problem. Also having a wide gap between allocated and used heap only mean that probably that memory was used before, but you do not know if it was used by a number of tiny objects or just by a few big ones. And, of course, you cannot infer how many times they were stored and released or things like that. As told before, I will try to put some bugsense code for further versions, to see if I can gather more reliable and precise information on heap state on these crashes. your heap is heavily fragmented, your process have allocated 48MB and released a lot (since there is 15MB), that's suggest lots of memory operations. My guess is that you are leaking memory between restarts, through some caches or other "global" (static) stuff. After few cycles of enter->exit OOM happens, I'd check if after exiting from game memory is correctly freed. Memory is corrrectly freed after exiting from the game. Did you check with MAT? Also you may try to verify this theory by forcing process termination with System.exit. I've doing that since half hundred of versions ago, more or less, so I am pretty sure about it. Bests, -- Regards, Bart -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
W dniu piątek, 23 listopada 2012 12:31:22 UTC+1 użytkownik Fran napisał: > > On 11/23/2012 10:30 AM, a1 wrote: > > > As told to Mark, I do not think so: the game is just starting, loading >> the first Screen at all. >> > > Really? > > Well, that's what I can see on that stack trace. > But you don't know if this is first run hence you cannot make assumption about process heap state (moreover other data suggest that this is not the case). > Data suggest quite the contrary: > > I think that data may suggest a wide number of different things. > If the data is valid (heap size and allocation size) this means that at least at some point your process allocated around 48MB total (if you check android heap management sources you will notice that heap grow algorithm do not excessively over-allocate) and when OOM occurs you still have 33MB allocated. All of above suggest a lot of allocation. > your heap is heavily fragmented, your process have allocated 48MB and > released a lot (since there is 15MB), that's suggest lots of memory > operations. My guess is that you are leaking memory between restarts, > through some caches or other "global" (static) stuff. After few cycles of > enter->exit OOM happens, I'd check if after exiting from game memory is > correctly freed. > > Memory is corrrectly freed after exiting from the game. > Did you check with MAT? Also you may try to verify this theory by forcing process termination with System.exit. -- Regards, Bart -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
On 11/23/2012 10:30 AM, a1 wrote: As told to Mark, I do not think so: the game is just starting, loading the first Screen at all. Really? Well, that's what I can see on that stack trace. Data suggest quite the contrary: I think that data may suggest a wide number of different things. your heap is heavily fragmented, your process have allocated 48MB and released a lot (since there is 15MB), that's suggest lots of memory operations. My guess is that you are leaking memory between restarts, through some caches or other "global" (static) stuff. After few cycles of enter->exit OOM happens, I'd check if after exiting from game memory is correctly freed. Memory is corrrectly freed after exiting from the game. Anyway I will try to add code to gather more information from the heap for further releases, if it is possible, so I can limit the potential causes. Thanks for your answer, Regards, Bart -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
You cannot use it all if you have images with alpha transparency, that's the case of many images in most games, and so its in my game. Actually I already use RGB_565 where I can. Best regards, On 11/23/2012 10:46 AM, b0b wrote: A good way to cut bitmap memory usage in half is to load them with BitmapFactory.Options.inPreferredConfig = Bitmap.Config.RGB_565. Eg 16 bits vs 32 bits. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
A good way to cut bitmap memory usage in half is to load them with BitmapFactory.Options.inPreferredConfig = Bitmap.Config.RGB_565. Eg 16 bits vs 32 bits. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
> As told to Mark, I do not think so: the game is just starting, loading > the first Screen at all. > Really? Data suggest quite the contrary: your heap is heavily fragmented, your process have allocated 48MB and released a lot (since there is 15MB), that's suggest lots of memory operations. My guess is that you are leaking memory between restarts, through some caches or other "global" (static) stuff. After few cycles of enter->exit OOM happens, I'd check if after exiting from game memory is correctly freed. Regards, Bart -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: OOM with heap enough
As told to Mark, I do not think so: the game is just starting, loading the first Screen at all. Also I have never experienced such problems on my own devices or emulators, and I have spent many time watching DDMS... of course it cannot be discarded at 100%, though. Regards, On 11/21/2012 04:03 PM, bob wrote: Maybe your heap is heavily fragmented and there is not 1.5megs of contiguous space? On Wednesday, November 21, 2012 8:50:41 AM UTC-6, Fran wrote: Look at this: 0java.lang.OutOfMemoryError: (Heap Size=48547KB, Allocated=33541KB) 1at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 2at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:595) 3at com.badlogic.androidgames.framework.impl.AndroidGraphics.newPixmap(AndroidGraphics.java:77) 4at com.badlogic.androidgames.framework.impl.AndroidGraphics.newPixmap(AndroidGraphics.java:133) 5at net.iberdroid.ruletaafortunadacore.MainMenuScreen.loadImages(MainMenuScreen.java:255) 6at net.iberdroid.ruletaafortunadacore.MainMenuScreen.enable(MainMenuScreen.java:241) The image that I am trying to load at MainMenuScreen.java:255 The weird thing is that there is free heap enough for loading that image: it is a 800x480 png indexed but with transparency, so I load it using four bytes per pixel (ARGB) and it should use about 1M5 of memory as a raw bitmap... but it crashes anyway trying to load an image ten times smaller the available heap space (48-35 = 15Mb). These things makes me crazy... Bests, -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en