Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中从服务器加载多个映像会导致VM Buget内存不足吗?_Android - Fatal编程技术网

在android中从服务器加载多个映像会导致VM Buget内存不足吗?

在android中从服务器加载多个映像会导致VM Buget内存不足吗?,android,Android,我使用的是lazy loader示例,但我的应用程序在Logcat中给出了以下错误 12-14 15:27:55.987: E/dalvikvm-heap(27566): 2457600-byte external allocation too large for this process. 12-14 15:27:55.992: E/(27566): VM won't let us allocate 2457600 bytes 12-14 15:27:55.992: D/skia(2756

我使用的是lazy loader示例,但我的应用程序在Logcat中给出了以下错误

12-14 15:27:55.987: E/dalvikvm-heap(27566): 2457600-byte external allocation too large for this process.

12-14 15:27:55.992: E/(27566): VM won't let us allocate 2457600 bytes

12-14 15:27:55.992: D/skia(27566): --- decoder->decode returned false
我在那篇文章中使用Imageloader类

  private Bitmap decodeFile(File f){
            try {
                //decode image size
                BitmapFactory.Options o = new BitmapFactory.Options();
                o.inJustDecodeBounds = true;
                o.inPurgeable = true; // Tell to garbage collector that whether it needs free memory, the Bitmap can be cleared
                o.inTempStorage = new byte[32 * 1024];
                BitmapFactory.decodeStream(new FileInputStream(f),null,o);

                //Find the correct scale value. It should be the power of 2.
                final int REQUIRED_SIZE=70;
                int width_tmp=o.outWidth, height_tmp=o.outHeight;
                int scale=1;
                while(true){
                    if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
                        break;
                    width_tmp/=2;
                    height_tmp/=2;



                      scale*=2; 


                }

                //decode with inSampleSize
                BitmapFactory.Options o2 = new BitmapFactory.Options();
                o2.inPurgeable = true; // Tell to garbage collector that whether it needs free memory, the Bitmap can be cleared
                o2.inTempStorage = new byte[32 * 1024];
                o2.inSampleSize=scale;
                Bitmap bitmap1=BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
              //  System.out.println("width : "+bitmap1.getWidth()+ " height : "+bitmap1.getHeight());
           /*     if(bitmap1.getHeight()>=bitmap1.getWidth())
                {

                    bitmap1 = Bitmap.createScaledBitmap(bitmap1, bitmap1.getHeight(),bitmap1.getWidth(), true);
                }else{
                    //bmp = Bitmap.createScaledBitmap(bmp, (int) height2,width, true);
                    Matrix matrix = new Matrix();

                    matrix.postRotate(270);
                    bitmap1 = Bitmap.createBitmap(bitmap1 , 0, 0, bitmap1 .getWidth(), bitmap1 .getHeight(), matrix, true);

                }*/
                return bitmap1;
            } catch (FileNotFoundException e) {}
            return null;
        }
私有位图解码文件(文件f){
试一试{
//解码图像大小
BitmapFactory.Options o=新的BitmapFactory.Options();
o、 inJustDecodeBounds=true;
o、 inpurgable=true;//告诉垃圾收集器是否需要空闲内存,位图可以被清除
o、 inTempStorage=新字节[32*1024];
解码流(新的FileInputStream(f),null,o);
//找到正确的刻度值。它应该是2的幂。
所需的最终int_尺寸=70;
内部宽度=o.向外宽度,高度=o.向外高度;
int标度=1;
while(true){

如果(width_tmp/2你不需要做所有这些。试试这个库。这太棒了。
你不需要做所有这些。试试这个库。这太棒了。

我建议您使用该库,它比Android Universal Image Loader简单,但同样强大。

我建议您使用该库,它比Android Universal Image Loader简单,但同样强大。

使用该库加载图像您在哪里设置了
o.inJustDecodeBounds=false;
我尝试了,但没有解决方案使用此库加载图像的用户您在哪里设置了
o.inJustDecodeBounds=false;
我尝试了,但没有解决方案…我需要在github上阅读它。它很简单。如果您发现任何问题,请询问我。nitesh…此项目不重要,它只有一个jar。您只需要在库中导入它。只需转到该页面上的快速设置。just read on github。它很简单。如果你发现任何问题,请问我。nitesh…这个项目不重要,它只有一个jar。你只需要在你的库中导入它。只需转到该页面上的快速设置。只需下载文件.jar并配置“构建路径”然后按照教程中的链接就很容易了。只需下载文件.Jar并配置“构建路径”,然后按照教程中的链接就很容易了。