flexbox-layout icon indicating copy to clipboard operation
flexbox-layout copied to clipboard

FlexboxLayoutManager will throw OOM if Adapter's item count is too many.

Open eneim opened this issue 6 years ago • 1 comments

  • [x] I have searched existing issues and confirmed this is not a duplicate

Issues and steps to reproduce

FlexboxLayoutManager will throw OOM if number of item is too many. To reproduce this, simply return Integer.MAX_VALUE from Adapter.

I could see that you save a cache of Measure spec/size in an array of long whose size is depended on number of Item multiple by 2. This is the root cause, but I don't know the mindset behind the use of this Array, so I could not put any effort to fix this at the moment. Removing or Changing the use of this Array could break the FlexboxLayout too.

Expected behavior

From my investigating with other built-in LayoutManager, Integer.MAX_VALUE would not crash any of them. I expect FlexboxLayoutManager could be like this too.

Version of the flexbox library

Latest: 0.3.1

Link to code

N/A

eneim avatar Nov 09 '17 11:11 eneim

Thanks for filing this. The reason why measured results are cached is to reuse the same calculation logic for flexbox for both FlexboxLayout and FlexboxLayoutManager. An individual view from FlexboxLayoutManager isn't retrieved in the same way as FlexboxLayout during calculation.

Anyway I'll have a look if that allocation can be reduced.

thagikura avatar Nov 10 '17 01:11 thagikura