When to release objects in mono touch / mvvmcross

We are implementing an application that seems to have serious memory leaks. For example, we have a view with its aggressive viewing model, which is registered 38 times in the mono-profiler, but it must be garbage collection. We have many custom controls, etc., but where should they be disposed of - with ios 6, viewdidunload is no longer called, and where should we do the cleanup?

considers

+2
source share
2 answers

This is a big question ... and it is not easy to answer the general case.

In general, if you write nice simple ViewModels and beautiful simple views, then you won't get memory leaks.

, , ViewModels, , , , - , - .


- ObjC # . http://forums.xamarin.com/discussion/97/correct-way-to-pop-a-dialogviewcontroller-mine-are-staying-in-memory, , - SQL- - https://github.com/slodge/MvvmCross/issues/19

, Rolf answer - http://forums.xamarin.com/discussion/comment/535/#Comment_535 - - , !


, ...

  • ,

  • , - , .

  • .

, 1 2, 3. "", , , .

, Mono - , - .

, , , , , http://docs.xamarin.com/ios/Guides/Deployment%252c_Testing%252c_and_Metrics/Monotouch_Profiler


, , , 3 , , , .

:

  • ... - .
  • "" , , .
  • 'willappear', 'willdisappear', , / .
  • , #. Messenger, TinyMessenger ( MvvmCross -) - , WeakReference, .
  • "-" " " - "-" " " -

, . , MvvmCross -MonoTouch, MvvmCross IoC .


MvvmCross, , , - !

MvvmCross - , , WeakReferences - . https://github.com/slodge/MvvmCross/issues/17 - - ... . .


:

..,

.

, , , - , . , Dispose() . , ()

+5

, , NSObject, , WeakReference.

:

 // MyView is a UIView, which is an NSObject, so the rule will apply here
 class MyView : UIView {
       WeakReference<UIViewController> myController;

       public MyView (RectangleF bounds, UIViewController myContainer) 
           : base (bounds) {
           this.myController = myContainer;
       }
 }
+1

All Articles