To create infinite scrolling, I'm trying to use either
- List or
- Lazy Stack in a ScrollView.
In both the cases I've noticed that as we scroll down and keep adding views, the memory footprint keeps on growing until the app crashes. (On a real device, not on a simulator)
Repo: https://github.com/advantej/Flights Project contains 3 different view representations of the collection of items: with List, ScrollView/LazyVStack and UITableView wrapped.
As you switch between these 3, it is observed that the memory footprint keeps on growing for the List and ScrollView/LazyVStack. But it does remain pretty much constant for the wrapped UITableView. See attached memory graph.
Questions:
-
Is there anything incorrect that is being done here?
-
If not, what is the recommended way of dealing with infinite scroll using SwiftUI List or ScrollView/LazyVStack?