SwiftUI : List or Lazy Stack running out of memory

To create infinite scrolling, I'm trying to use either

  1. List or
  2. 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:

  1. Is there anything incorrect that is being done here?

  2. If not, what is the recommended way of dealing with infinite scroll using SwiftUI List or ScrollView/LazyVStack?

For the list and lazy v stack views debug the view hierarchy and see what underlying UIKit controls are being used.

SwiftUI : List or Lazy Stack running out of memory
 
 
Q