Post

Replies

Boosts

Views

Activity

Reply to Images retain memory usage
Hello lunar-serenade, I think that has to do with some SwiftUI internal stuff. I think as long as there is more than enough memory available, the images will be kept in cache for a certain amount of time. If I remember correctly, you can "bypass" the cache by using the init(uiImage: UIImage) initializer, and initializing the UIImage with this initializer: init?(contentsOfFile path: String) Also, I have some functionality in my App which loads a lot of stuff into the memory and often caused my app to crash, because it exceeded the maximum allowed memory usage. After doing a lot of research and debugging, I found out that wrapping all the code (that loads the files into memory) in a try! autoreleasepool { ... } did the trick. To me it seems that the Swift garbage collections doesn't work very reliable. I don't recommend this approach, since garbage collection should be completely handled by Swift itself. But right now this is the only method that worked for me. Please let us know if this could fix your problem. Thanks!
May ’24