0
我想了解Xamarin.iOS需要的內存管理。Xamarin.iOS/monotouch內存管理
在下列情況下,不this.NavigationController.PopToRootViewController釋放創建UIViewControllers或 我應該釋放他們?如果我需要這樣做,應該在哪裏完成?
每個字母代表一個UIViewController)
A(RootViewController的)
從A:
B b = new B()
this.NavigationController.PushViewController (b, true);
從B:
C c = new C()
this.NavigationController.PushViewController (c, true);
從C:
D d = new D()
this.NavigationController.PushViewController (d, true);
從d:
this.NavigationController.PopToRootViewController(true);
謝謝,我正在嘗試這種配置。但現在,我在XCode Instruments Allocations中看到的結果有點奇怪,因爲我沒有看到任何正在釋放的內存,即使我明確地配置了某些對象,而且在之前的配置中我也有看到發佈。 我不得不提及,我遠不是使用XCode Instruments Allocations的專家。 – 2014-10-29 12:08:24
根據我的經驗,避免使用Xamarin時的內存泄漏非常困難。我們的應用程序有一個代碼路徑,它或多或少地重新啓動應用程序,重建所有對象並忘記舊的應用程序。但是老舊的東西在記憶中流連忘返,我花了100個小時試圖擺脫它們。只有通過Dispose()方法和nulling引用才能取得進展,但這樣的策略很容易引入錯誤。 – Outback 2015-02-10 22:23:28