我在我的应用程序中使用Picasso库最新版本2.4.0来下载和缓存图像.大约有25-30张图像,每张300KB-400KB.我认为这不是一件大事或沉重的事情.
即使应用程序运行正常,我的logcat中的内存分配也没有了.谁能解释为什么会这样?
在GridView适配器中加载图像的代码:
Picasso.with(mContext).load(getUrl()).placeholder(R.drawable.placeholder)
.into(viewholder.image);
Run Code Online (Sandbox Code Playgroud)
这是我的Logcat输出:
I/dalvikvm-heap(11142): Grow heap (frag case) to 53.860MB for 2720016-byte allocation
I/dalvikvm-heap(11142): Forcing collection of SoftReferences for 3265936-byte allocation
E/dalvikvm-heap(11142): Out of memory on a 3265936-byte allocation.
I/dalvikvm(11142): "Picasso-/images/posters/34.71.jpg" prio=5 tid=18 RUNNABLE
I/dalvikvm(11142): | group="main" sCount=0 dsCount=0 obj=0x4283f248 self=0x60a47830
I/dalvikvm(11142): | sysTid=11196 nice=10 sched=0/0 cgrp=apps/bg_non_interactive I/dalvikvm(11142): | state=R schedstat=( 2070202497 1858185620 3947 ) utm=172 stm=35 core=3
I/dalvikvm(11142): at android.graphics.Bitmap.nativeCreate(Native Method)
I/dalvikvm(11142): at android.graphics.Bitmap.createBitmap(Bitmap.java:726)
I/dalvikvm(11142): at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
I/dalvikvm(11142): at android.graphics.Bitmap.createBitmap(Bitmap.java:636)
I/dalvikvm(11142): at com.squareup.picasso.BitmapHunter.transformResult(BitmapHunter.I/dalvikvm(11142): at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:168)
I/dalvikvm(11142): …Run Code Online (Sandbox Code Playgroud)