简体   繁体   English

Android图像加载器的可用内存

[英]Free memory for android image loader

I am new to Android and i would like your advices on Volley Image loader. 我是Android的新手,我想就Volley Image loader提出您的建议。 I have developed an application to load images using Volley Image loader. 我开发了一个使用Volley Image loader加载图像的应用程序。 However, once I request to load more than 100 images, the performance and application will slow down and sometimes return OOM error. 但是,一旦我请求加载100个以上的图像,性能和应用程序就会变慢,有时会返回OOM错误。 Would like to ask whether by running line of code below, am I able to free memory ? 想问一下是否可以通过下面的代码行来释放内存? what is the best practises to free memory in an application ? 在应用程序中释放内存的最佳实践是什么? How to manage memory using Volley image loader so that we can avoid OOM error? 如何使用Volley图像加载器管理内存,从而避免OOM错误?

Runtime.getRuntime().freeMemory()

Clearing memory manually is highly discouraged. 不建议手动清除内存。 The GC is supposed to do it and you should not interfere with it. GC应该这样做,您不应该干预它。 In your volley implementation, you may use a caching (Memory and / or Disk)mechanism to improve your app's performance. 在排球实现中,您可以使用缓存(内存和/或磁盘)机制来提高应用程序的性能。 Have a look at their sample repo here https://github.com/rdrobinson3/VolleyImageCacheExample where they are demonstrating the use of disk based caching for Volley. https://github.com/rdrobinson3/VolleyImageCacheExample上查看其示例存储库,他们在其中演示了Volley使用基于磁盘的缓存的情况。

If I were you, I would use Picasso or Glide (recommended by Google) for loading network images in my app. 如果您是我,则可以使用PicassoGlide (Google推荐)在我的应用中加载网络图片。 These libraries handle caching internally so you don't have to worry about it. 这些库在内部处理缓存,因此您不必担心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM