When I have a view controller pushed to navigation stack of UINavigationController I create a scroll view and add one to the View of the view controller. The view controller is then set as WeakDelegate of the scroll view added. When the view controller is then popped from the navigation stack it doesn't get released (Dispose(disposing) method is not called). Seems like WeakDelegate reference is keeping it alive, but I don't pretty understand why garbage collector doesn't collect the view controller that is not referenced from anywhere else. A simple test project is here.
Sounds like a strong reference cycle. Your view controller is referencing the scroll view and the scroll view is in turn referencing your view controller. See these guides for more info:
and
Answers
Sounds like a strong reference cycle. Your view controller is referencing the scroll view and the scroll view is in turn referencing your view controller. See these guides for more info:
https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/performance/#Avoid_Strong_Circular_References
and
https://developer.xamarin.com/guides/cross-platform/deployment,_testing,_and_metrics/memory_perf_best_practices/#Use_Weak_References_to_Prevent_Immortal_Objects
Thank you Jon, for reply and resources links. My main concern was about GC - I thought it should take care of possible reference cycles but seems like it is is still required to apply best practices from reference count pattern. Seems like in Xamarin.iOS there is a mixture of approaches on memory management if I understand that right.