Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.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 如何避免OutOfMemoryError_Android_Performance_Image Processing_Memory Leaks_Out Of Memory - Fatal编程技术网

Android 如何避免OutOfMemoryError

Android 如何避免OutOfMemoryError,android,performance,image-processing,memory-leaks,out-of-memory,Android,Performance,Image Processing,Memory Leaks,Out Of Memory,我试图在每个水平列表视图中加载20个图像。我的RecyclerView包含7个水平Listview,每个Listview包含20个图像。当我单击任何Listview查看图像详细信息并按Back键时。当我继续此步骤4次时,我的内存不足错误 如何避免内存不足错误 你还可以建议, 哪种图像加载器最适合一次加载大量图像而无需 占用大量的运行时内存 包含高分辨率图像的ListView向下缩放图像 不确定它是否对您有帮助,但请尝试此代码 @Override public void onLowMemory

我试图在每个水平列表视图中加载20个图像。我的RecyclerView包含7个水平Listview,每个Listview包含20个图像。当我单击任何Listview查看图像详细信息并按Back键时。当我继续此步骤4次时,我的内存不足错误

如何避免内存不足错误

你还可以建议,

  • 哪种图像加载器最适合一次加载大量图像而无需 占用大量的运行时内存
  • 包含高分辨率图像的ListView向下缩放图像

  • 不确定它是否对您有帮助,但请尝试此代码

      @Override
    public void onLowMemory() {
        super.onLowMemory();
        System.gc(); // clear bitmap and other objects here to reduce memory. 
    }
    

    我更喜欢用毕加索或Glide来显示图像。有条纹的毕加索和凌空的ImageLoader。但它仍然需要72mb的堆。你是否在毕加索中将图像缩放到图像视图大小。如果没有,请这样做。是否有此链接@通过NivedhGo并尝试使用.resize()毕加索.with(context).load(url).resize(50,50).centerCrop().into(imageView)可以减少内存不足问题还有其他解决方案吗?