开发者

outOfMemoryException in game Android

I have been writing an android game, and I finally got everything done, and it ran perfectly fine on the emulator and on my phone, which is a rooted droid, but when I put in the marketplace I began getting reports of it force closing, I had my parents put it on their phone and it force closed when they tried to click the start button in the on screen menu, but my friends died when he tried to reopen it after playing it. I have his logcat, but I am not sure about my parents stuff yet. Here it is

07-18 23:58:32.457: ERROR/AndroidRuntime(25513): FATAL EXCEPTION: main
07-18 23:58:32.457: ERROR/AndroidRuntime(25513): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.Bitmap.nativeCreate(Native Method)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at androi开发者_如何学JAVAd.graphics.BitmapFactory.decodeResource(BitmapFactory.java:346)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:372)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at com.Waldev.cannontrial.CannonBlast$panel.<init>(CannonBlast.java:136)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at com.Waldev.cannontrial.CannonBlast.onCreate(CannonBlast.java:41)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.os.Looper.loop(Looper.java:123)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at java.lang.reflect.Method.invokeNative(Native Method)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at java.lang.reflect.Method.invoke(Method.java:521)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-18 23:58:32.457: ERROR/AndroidRuntime(25513):     at dalvik.system.NativeStart.main(Native Method)
07-18 23:58:32.487: WARN/ActivityManager(85):   Force finishing activity com.Waldev.cannontrial/.CannonBlast

I am not sure why it would do this, I thought that I had closed out the game cleanly, but thats not even the issue because my parents can't even get the game to open. Is there something that might have caused this to happen that is common? I added a few things to the manifest like finishOnTaskLaunch and stuff like that, but nothing seems to remedy the situation. Any ideas? And do you need anything else to see what might be going on, I will be around trying to fix this until it gets done, so I will comment pretty quickly. Thanks in advance


Try this stackoverflow question:

java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android

Your question is likely to be closed by the way, because it's a duplicate. But the question and solution I linked to should help you out.


It depends on the way you're loading and managing your bitmaps. (For example, are you sure you're not reloading bitmaps during every onDraw() call?)

You can also reduce the amount of memory your bitmaps take up by increasing the sample size during loading:

Context c = myActivity; // Some activity
BitmapFactory.Options options = new BitmapFactory.Options();

// 4 here means your resulting bitmap will be 1/4 width and height => 1/16 size
options.inSampleSize = 4; // Powers of 2 are better

BitmapFactory.decodeResource(c.getResources(), R.drawable.sample_bitmap, options);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜