小图用 imageNamed: 大图用 dataWithContentsOfFile:options
1down voteaccepted |
If you're loading images like: Besides that, when you only push a view controller without pop it in future, then the view controller will never deallocated and will always take a place in memory until the app will not crashed/killed, or until the ViewController who holds that view controller will not deallocated. So, always make sure that you deallocated the viewController if there is no more need of it (i.e. pop it if it was pushed, or dismiss it in case if it was presented modally) and then show your next view controller. |
|||
-dataWithContentsOfFile:
, I would suggest using-dataWithContentsOfFile:options:
, and use theNSDataReadingMappedIfSafe
, so that you don't have the overhead of copying around the file's data to user-space until UIImage reads it. – Richard J. Ross IIIJul 10 at 20:03