Reputation: 4442
We know the static vs. singleton debate, so this question isn't about legitimacy of the static keyword.
When you have a static class, how is the memory for that handled by Monotouch. Are its members removed when a memory warning is received? Are there any guidelines regarding use of static classes in Monotouch?
Upvotes: 1
Views: 313
Reputation: 26505
Static classes and members will hang around the lifetime of your application.
Generally I wouldn't worry about static classes. The largest thing to worry about is making sure you are properly cleaning things up in ViewDidUnload
in all your controllers.
Here you should:
ReleaseDesignerOutlets
will do this in later versions of MonoTouch) you have to do it yourself for any views created from codeViewDidLoad
ViewDidUnload
should be a mirror image of ViewDidLoad
ViewDidUnload
is called on low memory conditions for controllers that are not currently on screen, such as ones down the stack in UINavigationControllers
, etc.
In addition, you might want to hook into the low memory notification from UINotificationCenter
on any helper classes that cache UIImage, UIFont, etc.
Freeing up views and images will free up much more memory that you would get by how much memory static classes are using.
Upvotes: 4