在凌空库内存不足错误

在凌空库内存不足错误

本文介绍了在凌空库内存不足错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在做什么,首先进入Customadapter的构造函数,我用来初始化图像缓存和图像加载器

This is what I am doing, Firstly into the constructor of Customadapter, I have initilize image cache and image loader

imageCache = new BitmapLruCache();
mImageLoader =  new ImageLoader(newRequestQueue(context), imageCache);

然后进入我也做了getView()方法...

then into the getView() method I have done...

String url = imgs[position];
image.setImageUrl(url, mImageLoader);
image.setDefaultImageResId(R.drawable.no_image);
image.setErrorImageResId(R.drawable.error_image);

其中IMGS为位图的URL和图像阵列是NetworkImageView的对象。当我执行它,我得到了内存不足的错误。这是我的logcat的O / P: -

Where imgs is the array for bitmaps url and image is the object of NetworkImageView. When I execute it, I got error of OutOfMemory. This is my logcat o/p :-

    02-24 12:08:08.845: E/dalvikvm-heap(6288): Out of memory on a 144636048-byte allocation.
02-24 12:08:08.845: I/dalvikvm(6288): "main" prio=5 tid=1 RUNNABLE
02-24 12:08:08.845: I/dalvikvm(6288):   | group="main" sCount=0 dsCount=0 obj=0x41767b50 self=0x417571d0
02-24 12:08:08.845: I/dalvikvm(6288):   | sysTid=6288 nice=0 sched=0/0 cgrp=apps handle=1075191004
02-24 12:08:08.845: I/dalvikvm(6288):   | state=R schedstat=( 0 0 0 ) utm=116 stm=35 core=1
02-24 12:08:08.845: I/dalvikvm(6288):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:815)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.content.res.Resources.loadDrawable(Resources.java:1992)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.content.res.Resources.getDrawable(Resources.java:666)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.widget.ImageView.resolveUri(ImageView.java:616)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.widget.ImageView.setImageResource(ImageView.java:349)
02-24 12:08:08.855: I/dalvikvm(6288):   at com.android.volley.toolbox.NetworkImageView$1.onResponse(NetworkImageView.java:177)
02-24 12:08:08.855: I/dalvikvm(6288):   at com.android.volley.toolbox.NetworkImageView$1$1.run(NetworkImageView.java:168)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.os.Handler.handleCallback(Handler.java:725)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.os.Handler.dispatchMessage(Handler.java:92)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.os.Looper.loop(Looper.java:137)
02-24 12:08:08.855: I/dalvikvm(6288):   at android.app.ActivityThread.main(ActivityThread.java:5099)
02-24 12:08:08.855: I/dalvikvm(6288):   at java.lang.reflect.Method.invokeNative(Native Method)
02-24 12:08:08.865: I/dalvikvm(6288):   at java.lang.reflect.Method.invoke(Method.java:511)
02-24 12:08:08.865: I/dalvikvm(6288):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
02-24 12:08:08.865: I/dalvikvm(6288):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
02-24 12:08:08.865: I/dalvikvm(6288):   at dalvik.system.NativeStart.main(Native Method)
02-24 12:08:08.865: D/skia(6288): --- decoder->decode returned false
02-24 12:08:08.865: D/AndroidRuntime(6288): Shutting down VM
02-24 12:08:08.865: W/dalvikvm(6288): threadid=1: thread exiting with uncaught exception (group=0x41766ae0)
02-24 12:08:08.875: E/AndroidRuntime(6288): FATAL EXCEPTION: main
02-24 12:08:08.875: E/AndroidRuntime(6288): java.lang.OutOfMemoryError
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:815)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.content.res.Resources.loadDrawable(Resources.java:1992)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.content.res.Resources.getDrawable(Resources.java:666)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.widget.ImageView.resolveUri(ImageView.java:616)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.widget.ImageView.setImageResource(ImageView.java:349)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at com.android.volley.toolbox.NetworkImageView$1.onResponse(NetworkImageView.java:177)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at com.android.volley.toolbox.NetworkImageView$1$1.run(NetworkImageView.java:168)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.os.Handler.handleCallback(Handler.java:725)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.os.Looper.loop(Looper.java:137)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at android.app.ActivityThread.main(ActivityThread.java:5099)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at java.lang.reflect.Method.invokeNative(Native Method)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at java.lang.reflect.Method.invoke(Method.java:511)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
02-24 12:08:08.875: E/AndroidRuntime(6288):     at dalvik.system.NativeStart.main(Native Method)

我无法找到任何解决方案,为我工作,所以我应该怎么做?

I cant find any solution that will work for me, So What should I do...

推荐答案

由于板井Hanski先生

Thanks to Mr. Itai Hanski,

您有关OOM没有与网络组件做OOM的建议后,我曾在其他任何原因望出去,终于让我找到解决方法:

After your suggestion about OOM that OOM doesn't have to do with the network components, I had looked out on any other cause, Finally I found solution :

这是从列表视图项的布局文件,我已经将的android:SRC =进入ImageView的。
当我删除的ImageView这个XML属性的OOM问题解决了。

It was from layout file of listview item, I had set the android:src="" into the Imageview.When I remove this xml attribute from ImageView, The OOM problem resolve out.

但有一件事我还没有发现,当我设置错误或装载条件的图像错误再次出来的时候,我仍然不能uderstand什么是真正的原因。

But one thing I still not found that when I set a image for error or loading condition the error again comes out, still I cant uderstand what the real cause of it.

这篇关于在凌空库内存不足错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 01:28