时内存的API 23启动应用程序 [英] Out of memory when start app on api 23

查看:256
本文介绍了时内存的API 23启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点失望,当我将开始测试我的银河S3应用在API 23我得到一个内存不足的错误,当我开始我的启动画面!喔。

I'm little bit dissapointed when i will start to test my app on galaxy S3 in API 23. I get an out of memory error when i start my splash screen ! Whoo.

02-01 20:17:29.110: E/AndroidRuntime(6304): FATAL EXCEPTION: main
02-01 20:17:29.110: E/AndroidRuntime(6304): java.lang.OutOfMemoryError
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.content.res.Resources.loadDrawable(Resources.java:2988)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.content.res.Resources.getDrawable(Resources.java:1558)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3573)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3616)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:357)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.milesbox.sport.tracker.LoginActivity.onCreate(LoginActivity.java:11)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.Activity.performCreate(Activity.java:5372)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.access$700(ActivityThread.java:159)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.os.Looper.loop(Looper.java:176)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.main(ActivityThread.java:5419)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at java.lang.reflect.Method.invokeNative(Native Method)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at java.lang.reflect.Method.invoke(Method.java:525)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at dalvik.system.NativeStart.main(Native Method)

我的应用程序的API下10个工作井API 18。
在启动画面的活动,我有4个图标和背景图像(1900 * 1200像素〜400KB)。你有一个想法,以与出的内存没有问题,运行我的应用程序?

My app work well under API 10 to API 18. In the Splashscreen activity i have 4 icons and background image (1900*1200px ~ 400kb). Have you an idea to run my app with no problem of out of memory ?

推荐答案

要真正弄清楚,你需要上我们其他人也可以看到一个API工作!但是,它可能是API 23修改您的应用程序访问在规模增长的数据结构或对象。如果没有code和我们其他人一个适当的测试环境中,你可能无法得到太多,除了这个小技巧就在这里:

To really figure it out, you will need to work on an API that the rest of us can see also! However, it's possible that API 23 modifies data structures or objects that your app accesses that have grown in size. Without code and a proper test environment for the rest of us, you might not get much besides this little tip right here:

内存不足错误而载入位图

您可以随时请求扩展堆,但鉴于你的情况,这不是一个真正的补丁,它只是掩盖了真正的问题。

You can always request the expanded heap, but given your situation that's not a true fix, it only masks the real problem.

FYI - 如果你的背景是1900px * 1200像素那么它的存储器的alloc大概占用4 * 1900 * 1200 = 9MB(根据图像的类型,但通常其4个字节(每像素32位))。这是pretty大,真的。

FYI - if your background is 1900px * 1200px then it's memory alloc is probably taking up 4 * 1900 * 1200 = 9MB (depending on the type of image, but typically its 4 bytes (32-bits) per pixel). It's pretty large, really.

有关内存不足良好的整体环节 - 这是概率的最好的SO:

For a good overall link on "OutOfMemory" - this is prob the best on SO:

<一个href=\"http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object\">Strange内存不足的问题,同时加载到一个位图对象的图像

和基于设备/ API上堆的大小一个很好的链接:

and a good link on heap sizes based on device / API:

<一个href=\"http://stackoverflow.com/questions/14375947/is-there-a-minimal-heap-size-for-android-versions\">Is有一个最小堆大小为Android版本?

这篇关于时内存的API 23启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆