2014-06-17 22 views
7

我們正在使用畢加索從我們的應用程序中加載所有圖像,從小頭像到大型全屏圖像,我們每10位日常活躍用戶就會收到1個這樣的錯誤。畢加索的緩存正在填滿,但我們的理解是它應該保持自己。畢加索生產OutOfMemoryError

我們的日誌記錄顯示,在高端設備(Galaxy S4)上加載大型全屏圖像(1080x1920)和大型頭像(720x720)時,偶爾會在小型頭像(135x135)上加載這些錯誤的頻率最高。

com.couchsurfing.mobile.data.PicassoException: Error while loading image with Picasso 
     at com.couchsurfing.mobile.data.DataModule$1.onImageLoadFailed(DataModule.java:158) 
     at com.squareup.picasso.Picasso.complete(Picasso.java:374) 
     at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:97) 
     at android.os.Handler.dispatchMessage(Handler.java:99) 
     at android.os.Looper.loop(Looper.java:137) 
     at android.app.ActivityThread.main(ActivityThread.java:5419) 
     at java.lang.reflect.Method.invokeNative(Method.java) 
     at java.lang.reflect.Method.invoke(Method.java:525) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
     at dalvik.system.NativeStart.main(NativeStart.java) 
Caused by: java.lang.RuntimeException: ===============BEGIN PICASSO STATS =============== 
Memory Cache Stats 
    Max Cache Size: 19173961 
    Cache Size: 17988408 
    Cache % Full: 94 
    Cache Hits: 228 
    Cache Misses: 244 
Network Stats 
    Download Count: 131 
    Total Download Size: 3375735 
    Average Download Size: 25768 
Bitmap Stats 
    Total Bitmaps Decoded: 206 
    Total Bitmap Size: 144932008 
    Total Transformed Bitmaps: 160 
    Total Transformed Bitmap Size: 40233240 
    Average Bitmap Size: 703553 
    Average Transformed Bitmap Size: 195306 
===============END PICASSO STATS =============== 

     at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:117) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
     at java.lang.Thread.run(Thread.java:841) 
     at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394) 
Caused by: java.lang.OutOfMemoryError 
     at android.graphics.BitmapFactory.nativeDecodeStream(BitmapFactory.java) 
     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623) 
     at com.squareup.picasso.NetworkBitmapHunter.decodeStream(NetworkBitmapHunter.java:118) 
     at com.squareup.picasso.NetworkBitmapHunter.decode(NetworkBitmapHunter.java:72) 
     at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:144) 
     at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:101) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
     at java.lang.Thread.run(Thread.java:841) 
     at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394) 
+0

你是否在一個適配器中使用它? – Michael

+0

我們在整個應用程序中收到此錯誤。在ListAdapters PagerAdapters和正常佈局中。 – nathanielwolf

+0

您是否在整個應用程序中使用您自己的畢加索單件實例? – Michael

回答

1

我有同樣的問題,臨時解決方法之一是

<application 
    ... 
    android:largeHeap="true"> 

現在,我還沒有找到另一種解決方案(也許我已經搜查不夠)。但很多人與畢加索有OOM。

0

在加載圖片時,你正在請求fit()嗎?我懷疑這是我的問題,我假設自己的圖像與畢加索抽樣自己,但你仍然需要告訴它這樣做。