top of page

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

Writer: Hui WangHui Wang

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:

Comments


Never Miss a Post. Subscribe Now!

I am an iOS developer, and I will share some knowledge related to iOS development from time to time.

Thanks for submitting!

© 2022 by (Foks) Hui Wang

bottom of page