2015-12-14 31 views
0

我在某些时候在我的项目中出现此错误。但为什么?我真的很新的android编程可以帮助我吗?我不知道为什么我得到这个错误。Android:OutOfMemoryError:未能分配36000012字节分配,16777120空闲字节和28MB直到OOM

12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime: FATAL EXCEPTION: main 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime: Process: com.cgame.angebotliste, PID: 32649 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 36000012 byte allocation with 16777120 free bytes and 28MB until OOM 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at dalvik.system.VMRuntime.newNonMovableArray(Native Method) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:741) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:562) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.content.res.Resources.loadDrawableForCookie(Resources.java:3702) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.content.res.Resources.loadDrawable(Resources.java:3575) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.content.res.Resources.getDrawable(Resources.java:1848) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.content.res.Resources.getDrawable(Resources.java:1814) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at com.squareup.picasso.RequestCreator.getPlaceholderDrawable(RequestCreator.java:676) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at com.squareup.picasso.RequestCreator.into(RequestCreator.java:664) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at com.cgame.angebotliste.BeichteShow_Adapter.loadImageFromUrl(BeichteShow_Adapter.java:199) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at com.cgame.angebotliste.BeichteShow_Adapter.onBindViewHolder(BeichteShow_Adapter.java:100) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at com.cgame.angebotliste.BeichteShow_Adapter.onBindViewHolder(BeichteShow_Adapter.java:42) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5217) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5250) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4487) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
12-14 16:45:18.172 32649-32649/com.cgame.angebotliste E/AndroidRuntime:  at 
+0

“但为什么?” - 因为你正在尝试分配一大块内存(〜35MB)。在大多数设备上,你不会有大块的内存。可绘制的占位符太大,可能位于错误的目录中。 – CommonsWare

+0

当我在一个intent中进行一个http调用并且在这个调用之后非常快地用recyleview切换到另一个intent时,错误就出现了。我所有的图片都有〜50kb的大小,我没有超过34MB的图片 –

+0

“错误来了......”......在各种情况下。你*发生*使它重现这种方式,但会有其他人。 “我所有的图像都有〜50kb的大小” - 大概是指磁盘上的大小。重要的是内存中的解码大小,这将是10-30倍,再加上由于不同密度(与设备相比资源)而完成的任何重新缩放。 – CommonsWare

回答

0

你要加载非常大的图像:

BeichteShow_Adapter.loadImageFromUrl(BeichteShow_Adapter.java:199)

,你应该将其缩小,有很多关于做题这样做即:

OutOfMemory when loading large Background Image

+0

所有图像的大小约为50kb。对于具有100个图像的Recycleview,是否50kb大? –

0

我建议使用GlideFresco加载图像。这些libarries会自动为您处理这些边缘情况。

+0

我becom这个错误也与滑翔,nostra13 :( –

0

我有同样的错误,我通过重新启动amulator来修复它。这个解决方案并不适用于每一种情况,因为在我的情况下,即使我显示另一个项目,另一个项目也在运行。

与一些研究,我发现有时(我不知道为什么)地图应用程序不关闭它,仍然显示在手机或模拟器。

也许这有助于。

相关问题