Hi,

On Wed, Apr 18, 2012 at 9:55 AM, stevek <[email protected]> wrote:

> I have got a new MT app that seems to crash when memory is constrained.
>
> Starting the App I immediately get level 1 memory warnings due to all the
> other stuff that was running.
> Run my app for a few minutes and I get ( I assume) a level 2 warning and
> then all the ViewControllers begin to unload  and somewhere a selector is
> called on a GCd object.
>
> Is this correct behavior - I would assume the OS would try and unload
> background programs 1st before trying mine??
>
> Is the fix just to comment out base.DidReceiveMemoryWarning (); in
> DidReceiveMemoryWarning()  but would this just create more problems?
>

If you do this your app will not return any memory when you do get a memory
warning, and the likelyhood of getting killed by the OS increases.


>
> If not  - what what can I do to minimize the chance of a crash and clean up
> nicely - I have de-registered NSNotification centers during ViewDidUnload()
> - do I need to remove .Net event handlers as well?
>

There are a couple of things you can do:
* Use less memory yourself. MonoDevelop now has a memory profiler you can
use to track down memory leaks, or you can use Apple's Instruments to do
memory profiling to find out where memory is used.
* Some times you will still get memory warnings, so you'll need to handle
this the best way possible. This includes removing event handlers (to
events on objects derived from NSObject, not normal managed objects - the
easiest way to do this is to just the the .Delegate property to null),
calling Dispose on class-level objects and clearing out fields (once again
only fields defined on NSObjects).

Rolf
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to