Java 内存不足的Android Studio
我用13个活动和大量图像启动了Android项目,我的应用程序因内存不足而停止,但当我从图像视图中删除图片时,应用程序正常工作,但我使用了一些代码来调整位图大小和其他内容,没有任何工作,应用程序停止,内存监视器显示只有1或2 mb可用空间 我不知道如何继续 这是我的日志Java 内存不足的Android Studio,java,android,Java,Android,我用13个活动和大量图像启动了Android项目,我的应用程序因内存不足而停止,但当我从图像视图中删除图片时,应用程序正常工作,但我使用了一些代码来调整位图大小和其他内容,没有任何工作,应用程序停止,内存监视器显示只有1或2 mb可用空间 我不知道如何继续 这是我的日志 11-10 10:49:40.169 2704-2704/? I/art﹕ Not late-enabling -Xcheck:jni (already on) 11-10 10:49:40.169 27
11-10 10:49:40.169 2704-2704/? I/art﹕ Not late-enabling -Xcheck:jni (already on)
11-10 10:49:40.169 2704-2704/? I/art﹕ Late-enabling JIT
11-10 10:49:40.169 2704-2704/? I/art﹕ JIT created with code_cache_capacity=2MB compile_threshold=1000
11-10 10:49:40.219 2704-2704/teslicinfo.teslic W/System﹕ ClassLoader referenced unknown path: /data/app/teslicinfo.teslic-2/lib/x86
11-10 10:49:40.547 2704-2717/teslicinfo.teslic I/art﹕ Background partial concurrent mark sweep GC freed 81(3KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 6MB/10MB, paused 1.464ms total 120.600ms
11-10 10:49:40.677 2704-2713/teslicinfo.teslic W/art﹕ Suspending all threads took: 16.632ms
11-10 10:49:40.742 2704-2717/teslicinfo.teslic I/art﹕ Background sticky concurrent mark sweep GC freed 21(864B) AllocSpace objects, 0(0B) LOS objects, 0% free, 21MB/21MB, paused 1.278ms total 117.549ms
11-10 10:49:40.926 2704-2724/teslicinfo.teslic D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-10 10:49:40.972 2704-2704/teslicinfo.teslic D/﹕ HostConnection::get() New Host Connection established 0xab9908d0, tid 2704
11-10 10:49:41.045 2704-2724/teslicinfo.teslic D/﹕ HostConnection::get() New Host Connection established 0xab990dd0, tid 2724
11-10 10:49:41.066 2704-2724/teslicinfo.teslic I/OpenGLRenderer﹕ Initialized EGL, version 1.4
11-10 10:49:41.151 2704-2724/teslicinfo.teslic W/EGL_emulation﹕ eglSurfaceAttrib not implemented
11-10 10:49:41.151 2704-2724/teslicinfo.teslic W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xad92c960, error=EGL_SUCCESS
11-10 10:49:44.407 2704-2724/teslicinfo.teslic W/EGL_emulation﹕ eglSurfaceAttrib not implemented
11-10 10:49:44.407 2704-2724/teslicinfo.teslic W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xac13e200, error=EGL_SUCCESS
11-10 10:49:44.893 2704-2724/teslicinfo.teslic E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab9ac980
11-10 10:49:46.143 2704-2717/teslicinfo.teslic W/art﹕ Suspending all threads took: 13.446ms
11-10 10:49:46.147 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.147 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.149 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.149 2704-2704/teslicinfo.teslic I/art﹕ Clamp target GC heap from 34MB to 32MB
11-10 10:49:46.149 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.178 2704-2704/teslicinfo.teslic I/art﹕ Clamp target GC heap from 34MB to 32MB
11-10 10:49:46.178 2704-2704/teslicinfo.teslic I/art﹕ Alloc concurrent mark sweep GC freed 267(24KB) AllocSpace objects, 0(0B) LOS objects, 3% free, 30MB/32MB, paused 1.195ms total 27.810ms
11-10 10:49:46.182 2704-2704/teslicinfo.teslic I/art﹕ Forcing collection of SoftReferences for 1447KB allocation
11-10 10:49:46.182 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.195 2704-2704/teslicinfo.teslic I/art﹕ Clamp target GC heap from 34MB to 32MB
11-10 10:49:46.195 2704-2704/teslicinfo.teslic I/art﹕ Alloc concurrent mark sweep GC freed 11(344B) AllocSpace objects, 0(0B) LOS objects, 3% free, 30MB/32MB, paused 3.038ms total 12.420ms
11-10 10:49:46.198 2704-2704/teslicinfo.teslic W/art﹕ Throwing OutOfMemoryError "Failed to allocate a 1481772 byte allocation with 1096520 free bytes and 1070KB until OOM"
11-10 10:49:46.198 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.199 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.199 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.199 2704-2704/teslicinfo.teslic I/art﹕ Clamp target GC heap from 34MB to 32MB
11-10 10:49:46.199 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.211 2704-2704/teslicinfo.teslic I/art﹕ Clamp target GC heap from 34MB to 32MB
11-10 10:49:46.211 2704-2704/teslicinfo.teslic I/art﹕ Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 3% free, 30MB/32MB, paused 0 total 10.985ms
11-10 10:49:46.214 2704-2704/teslicinfo.teslic I/art﹕ Forcing collection of SoftReferences for 1447KB allocation
11-10 10:49:46.214 2704-2704/teslicinfo.teslic I/art﹕ Starting a blocking GC Alloc
11-10 10:49:46.227 2704-2704/teslicinfo.teslic I/art﹕ Clamp target GC heap from 34MB to 32MB
11-10 10:49:46.227 2704-2704/teslicinfo.teslic I/art﹕ Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 3% free, 30MB/32MB, paused 1.276ms total 12.712ms
11-10 10:49:46.229 2704-2704/teslicinfo.teslic W/art﹕ Throwing OutOfMemoryError "Failed to allocate a 1481772 byte allocation with 1096520 free bytes and 1070KB until OOM"
11-10 10:49:46.231 2704-2704/teslicinfo.teslic D/skia﹕ --- allocation failed for scaled bitmap
11-10 10:49:46.233 2704-2704/teslicinfo.teslic D/AndroidRuntime﹕ Shutting down VM
11-10 10:49:46.233 2704-2704/teslicinfo.teslic E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: teslicinfo.teslic, PID: 2704
java.lang.OutOfMemoryError: Failed to allocate a 1481772 byte allocation with 1096520 free bytes and 1070KB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1080)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2635)
at android.content.res.Resources.loadDrawable(Resources.java:2540)
at android.content.res.Resources.getDrawable(Resources.java:806)
at android.content.Context.getDrawable(Context.java:458)
at android.widget.ImageView.resolveUri(ImageView.java:811)
at android.widget.ImageView.setImageResource(ImageView.java:418)
at teslicinfo.teslic.diskotekeActivity.diskoteke_dzungla(diskotekeActivity.java:21)
at teslicinfo.teslic.diskotekeActivity.onCreate(diskotekeActivity.java:437)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-10 10:49:47.991 2704-2704/? I/Process﹕ Sending signal. PID: 2704 SIG: 9
您将图像保存在哪个可绘制文件夹中?当您有代码要显示时,不要链接到某些粘贴箱。把它放在这里。也可以查看,不要全部发布。还可以阅读或了解有关ListView或更新的RecyclerView的任何信息-您不应该因为看到的情况而自己构建一个非常长的scrollview。您是否尝试使用Traceview来查找?Traceview以前与Android一起提供。您的应用程序似乎试图加载~1.5 MB位图。也许你应该使用压缩图像格式,比如
png
或者jpg
?这可能会有帮助。我的照片中没有一张比250公里更大,我有10到13张这样大小的照片,其他的都是30kb左右。这里是traceview所有图像都在可绘制文件夹中,因为我只有“可绘制”文件夹。