MonoTouch is garbage collection, so you donโt have to worry about making the release yourself.
Speaking of this, there are times when you know that you are storing some large resources in memory, and you want to help the system by immediately saving resources, rather than waiting for the garbage collector to attack.
This is when the Dispose utility is called: it frees up resources associated before the garbage collector should. This is especially important for large objects, such as images, because images are stored in an unmanaged heap, and object references are stored in a managed heap.
This means that if you have an 8 megabyte image: 8 megabytes are stored in an unmanaged heap (managed by Objective-C) and 1 pointer (4 bytes) in a managed heap. As for the Mono Garbage Collector, you are using 4 bytes, not 8 megabytes.
So, the time has come when you can help the system by calling dispose: you know that the innocently looking variable myImage actually points to a large amount of memory.
miguel.de.icaza
source share