glide scaletype 无效_java – 内存不足错误在Glide中加载更多图像...

编辑:

>在我的应用程序中,我在主页上加载了300多张图像.我用滑动来加载图像.我出现了内存错误.

我在清单中使用了大堆true:

android:largeHeap="true"

滑翔版:

compile 'com.github.bumptech.glide:glide:3.7.0'

设备/ Android版本:

Nexus Device 6.0版本

Every images I’m getting from Json would be 800kb to 1mb.

activity_layout:

android:id="@+id/home_layout_bottom"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_below="@+id/home_layout_top_recycler"

android:layout_margin="5dp">

android:id="@+id/rv_list_tab_home_recycler"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:clipToPadding="false"

android:scrollbars="vertical"

android:visibility="visible" />

android:id="@+id/no_user_posts_item_tv_recycler"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/rv_list_tab_home_recycler"

android:layout_marginTop="80dp"

android:layout_centerHorizontal="true"

android:text="@string/txt_no_posts_available"

android:textColor="@color/txt_common_black"

android:textSize="@dimen/txt_size" />

适配器代码:

@Override

public View getView(int position, View convertView, ViewGroup parent) {

ViewHolder holder = null;

final HomePostItems rowItem = getItem(position);

LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);

if (convertView == null) {

convertView = mInflater.inflate(R.layout.lv_adapter_post_items_layout, null);

holder = new ViewHolder();

holder.ivPostedImage = (ImageView) convertView.findViewById(R.id.iv_posted_img);

convertView.setTag(holder);

} else {

holder = (ViewHolder) convertView.getTag();

}

..................

Glide.with(context).load(rowItem.getPosteduserpostimage())

.placeholder(R.drawable.golive_load_image).error(R.drawable.golive_cancel_image)

.override(600, 200)

.into(holder.ivPostedImage);

adapter_layout.xml:

android:id="@+id/rl_lv_user_post_adapter_img_holder_home"

android:layout_width="match_parent"

android:layout_height="300dp"

android:layout_marginLeft="1dp"

android:layout_marginRight="1dp"

android:layout_below="@+id/tv_user_posted_msg_post_items_home" >

android:id="@+id/iv_posted_img_home"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_centerInParent="true"

android:scaleType="fitXY"

android:background="#ffffff"

android:contentDescription="@string/cont_desc"/>

logcat的:

Request threw uncaught throwable

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Failed to allocate a 6365196 byte allocation with 865912 free bytes and 845KB until OOM

at java.util.concurrent.FutureTask.report(FutureTask.java:94)

at java.util.concurrent.FutureTask.get(FutureTask.java:164)

at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor.afterExecute(FifoPriorityThreadPoolExecutor.java:96)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1121)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)

at java.lang.Thread.run(Thread.java:818)

at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)

Caused by: java.lang.OutOfMemoryError: Failed to allocate a 6365196 byte allocation with 865912 free bytes and 845KB until OOM

at dalvik.system.VMRuntime.newNonMovableArray(Native Method)

at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)

at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:635)

at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:611)

at com.bumptech.glide.load.resource.bitmap.Downsampler.decodeStream(Downsampler.java:329)

at com.bumptech.glide.load.resource.bitmap.Downsampler.downsampleWithSize(Downsampler.java:220)

at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:153)

at com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(StreamBitmapDecoder.java:50)

at com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(StreamBitmapDecoder.java:19)

at com.bumptech.glide.load.resource.bitmap.ImageVideoBitmapDecoder.decode(ImageVideoBitmapDecoder.java:39)

at com.bumptech.glide.load.resource.bitmap.ImageVideoBitmapDecoder.decode(ImageVideoBitmapDecoder.java:20)

at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decodeBitmapWrapper(GifBitmapWrapperResourceDecoder.java:121)

at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decodeStream(GifBitmapWrapperResourceDecoder.java:94)

at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decode(GifBitmapWrapperResourceDecoder.java:71)

at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decode(GifBitmapWrapperResourceDecoder.java:61)

at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decode(GifBitmapWrapperResourceDecoder.java:22)

at com.bumptech.glide.load.engine.DecodeJob.decodeFromSourceData(DecodeJob.java:190)

at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:177)

at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)

at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)

at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)

at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)

at java.util.concurrent.FutureTask.run(FutureTask.java:237)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)

at java.lang.Thread.run(Thread.java:818)

at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)

我不知道如何解决这个OOM问题.如果您已经熟悉此问题,请分享您的建议.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值