简体   繁体   English

Android中任何列表的最大项目缓存限制

[英]Maximum item caching limit of any list in Android

What will happen if we keep on loading thousands of items in any type list in Android? 如果我们继续在Android的任何类型列表中加载数千个项目,将会发生什么? Will Android be able to recycle it correctly? Android能否正确回收它?

List is an Interface, not a class, so there are ArrayLists and LinkedLists and several other types, but ArrayLists for example can handle up to Integer.MAX_VALUE elements. List是一个接口,而不是一个类,因此有ArrayLists和LinkedLists以及其他几种类型,但例如ArrayLists最多可以处理Integer.MAX_VALUE元素。 I've never had a problem with an ArrayList and garbage collection at least and thousands of items is far below the limits of that class. 我从来没有遇到过ArrayList和垃圾回收问题,至少有数千个项目远低于该类的限制。

Short Answer 简短答案

In your case, there Would not be any problem in recycling of list view or recycler view. 就您而言,回收列表视图或回收者视图不会有任何问题。

Long Answer 长答案

The list view or recycler view would just load and show the amount of data which are visible on the UI. 列表视图或回收者视图仅会加载并显示在UI上可见的数据量。 So the size of the items in it is not any problem. 因此,其中项目的大小没有任何问题。

BUT

there are some cases which would make problem. 在某些情况下会产生问题。 for example if you put a recycler view inside a Scroll view! 例如,如果您将“回收者”视图放在“滚动”视图中! In such cases all of the items are loaded and there is no GC. 在这种情况下,所有项目均已加载,并且没有GC。 That's where you would have big problems with lots of data. 那是您处理大量数据的大问题。

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

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