top of page
Writer's pictureHui Wang

75. Article: When does a SwiftUI Environment get retained?

Environment is one of SwiftUI's unique features that aren't available in UIKit.


This article tells you how to manage the memory of the Environment while developing in SwiftUI.





The article's main points are as follows:

  1. Dispose of any SwiftUI View values not used anymore

  2. Dispose of any UIHostingController references not used anymore

  3. Watch out for memory leaks in:

  • UIViews used within SwiftUI

  • references between your UIViews and your environment objects

  • UIViewControllers presenting the UIHostingControllers

  • the environment objects themselves


References:


When does a SwiftUI Environment get retained?


 

Follow me on:

コメント


bottom of page