I am experimenting with using Swift and SwiftUI for processing genomics data. The hallmark of genomics data is very large data files. Common formats are text files known as fasta and fastq file formats. For the human genome, these files contain more than 40 million lines of text.
Being able to write code that can read such large files line by line is essential. After some trial and error and much reading I finally understand Automatic Reference Counting and the importance of using an autoreleasepool to prevent memory from being consumed.
I typically read such large files in a background thread and asynchronously update the UI (written in SwiftUI) using DispatchQueue.main.async by setting properties in my ContentView. This works fine. However, as I reach 40 million lines of text, updating the UI consumes memory without releasing it.
I have tried to incorporate autoreleasepools in the ContentView using the usual autoreleasepool { ... } syntax. However, within such constructs as VStacks, I encounter errors such as "Type () cannot conform to 'View"; only struct/enum/class types can conform to protocols"
It seems that autorelease pools do not play well with SwiftUI. What guidance is there for effectively managing memory with SwiftUI?
Thank you.
Being able to write code that can read such large files line by line is essential. After some trial and error and much reading I finally understand Automatic Reference Counting and the importance of using an autoreleasepool to prevent memory from being consumed.
I typically read such large files in a background thread and asynchronously update the UI (written in SwiftUI) using DispatchQueue.main.async by setting properties in my ContentView. This works fine. However, as I reach 40 million lines of text, updating the UI consumes memory without releasing it.
I have tried to incorporate autoreleasepools in the ContentView using the usual autoreleasepool { ... } syntax. However, within such constructs as VStacks, I encounter errors such as "Type () cannot conform to 'View"; only struct/enum/class types can conform to protocols"
It seems that autorelease pools do not play well with SwiftUI. What guidance is there for effectively managing memory with SwiftUI?
Thank you.