title: @StateObject never gets destroyed
body: <p>I am using @StateObject for creating a view model for my view. The problem is that the ViewModel is still in memory after closing the view and deinit is never called. If I open and close the view 10 times, the debug memory graph shows me 10 ViewModels. I created a very simple example to replicate the problem:</p>
  <pre><code>import SwiftUI
  
  struct MySwiftUIView: View {
      @Environment(\.presentationMode) private var presentation
      @StateObject var viewModel = MyViewModel()
  
          var body: some View {
                  Text(&quot;Hallo World.&quot;)
                      .navigationBarBackButtonHidden(true)
                      .navigationBarItems(leading: Button(
                          action: {
                              presentation.wrappedValue.dismiss()
                      },
                          label: { Text(&quot;back&quot;) }))
              }
      }
  
  class MyViewModel: ObservableObject {
      init() {
          print(&quot;&gt;&gt; init&quot;)
      }
  
      deinit {
          print(&quot;[x] deinit&quot;)
      }
  }
  </code></pre>
  <p>&quot;&gt;&gt; init&quot; is printed every time when I am opening the view, but &quot;[x] deinit&quot; is never printed.</p>
  <p>This is how I am opening the view:</p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      var body: some View {
          NavigationView {
              VStack{
                  NavigationLink(destination: MySwiftUIView()){Text(&quot;NavigationLink&quot;)}
              }
          }.navigationViewStyle(StackNavigationViewStyle())
      }
  }
  </code></pre>
  <p>Does anybody have an idea why the ViewModel never gets destroyed?</p>
  <p>I created a demo project in Xcode which can be found here: <a href="https://file.io/QQnHDvRNaGPP" rel="nofollow noreferrer">https://file.io/QQnHDvRNaGPP</a></p>