Android:OutOfMemoryError:无法分配36000012字节分配16777120个空闲字节和28MB直到OOM

时间:2015-12-14 15:56:46

标签: android out-of-memory picasso

我的项目有时会出现此错误。但为什么?我真的很新的android编程你能帮帮我吗?我不知道为什么我会收到这个错误。

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 

3 个答案:

答案 0 :(得分:0)

您正在尝试加载非常大的图片:

  

BeichteShow_Adapter.loadImageFromUrl(BeichteShow_Adapter.java:199)

你应该缩小它,有很多关于SO的问题,即:

OutOfMemory when loading large Background Image

答案 1 :(得分:0)

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

答案 2 :(得分:0)

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

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

也许这有帮助。