First MonoTouch usage of IDisposable is identical to Mono or .NET. What you read about this subject elsewhere, on stackoverflow or on MSDN... will all apply here.
What's important wrt MonoTouch is to remember that NSObject
implements IDisposable
which makes a lot of sense since it represent a native object. That means that everything that inherits from NSObject
, quite a large part of monotouch.dll, implements IDisposable
.
- What type of elements do I have to release in addition to images?
Most managed NSObject-based object instances are small but they can represent large native objects (the GC will only know about the first, managed, size).
So it's best to Dispose NSObject-based instances when you can, e.g. when you're using them as local variables. The using
pattern makes it easy to do so in C#.
OTOH use your judgment, a small NSString
won't take much memory, while others could be large (or unknown, e.g. NSString GetWebPageContent (NSUrl)
.
- Do I have to call the Dispose method from an instance of MyViewController class (myViewController.Dispose()) or the Dispose method is called automatically like dealloc method?
Part of the Dispose
pattern ensure that the finalizer will call Dispose
if it has not been called previously. As such the GC will, eventually, reclaim the memory (both managed and unmanaged/native) associated with those instances.
You might want to use some tools, like Gendarme (which will run on OSX) or FxCop (Windows-only) that will report to you (for example) if some of your types have IDisposable fields that are not disposed properly.
Disclaimer : I'm Gendarme's maintainer :-)