java - 使用glide載入圖片出現記憶體溢出
PHP中文网
PHP中文网 2017-05-17 10:07:15
0
1
1051

待處理異常java.lang.OutOfMemoryError:無法分配1125012 位元組分配,其中有784248 個可用位元組和765KB,直到OOM
com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream,android. graphics.BitmapFactory$Options , com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool, int, int, int, com.bumptech.glide.load.DecodeFormat) (Downsampler.java:217)##at androidgraphics##d .Bitmap com.bumptech .glide.load.resource.bitmap.Downsampler.decode(java.io.InputStream, com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool, int, int, com.bumptech.glide.load. DecodeFormat) (Downsampler. java:151)
at com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(java.io.InputStream, int, int) (StreamBitmapDecoder.java: 50)
at com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(java.lang.Object, int, int) (StreamBitmapDecoder .java:19)
at com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.resource.bitmap.ImageVideoBitmapDecoder.decode(com.bumptech.glide.load.model.ImageVideoWrapper, int, int) (ImageVideoBitmapDecoder.爪哇:39)

誰有解決方法,寄給我謝謝

PHP中文网
PHP中文网

认证0级讲师

全部回覆(1)
滿天的星座

看這個log並不能發現什麼,圖片載入出現oom是非常高機率的。
請仔細判斷
1)是否連續的加載了大圖而沒有及時回收?
2)是否哪裡記憶體洩漏了?
可以嘗試用LeakCanary檢查下記憶體洩漏,或是用工具持續檢查記憶體佔用狀況

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!