DiscussionIOS Memory OptimizationExperience is the content to be introduced in this article.IOSOfMemory OptimizationSolution. Let's look at the details first.
First, make sure that each retain, copy, and delloc has a release
1. CT... Create... is used to release CTRelease (myObject); CF is also true.
2. The following return is not released either.
- CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate (paragraphStyle_settings,
- Sizeof (paragraphStyle_settings)/sizeof (paragraphStyle_settings [0]);
- If (...)
- {
- <SPAN style = "WHITE-SPACE: pre"> </SPAN> return; // Overflow
- }
- CTRelease (paragraphStyle );
- CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate (paragraphStyle_settings,
- Sizeof (paragraphStyle_settings)/sizeof (paragraphStyle_settings [0]);
- If (...)
- {
- Return; // Overflow
- }
- CTRelease (paragraphStyle );
3. Sometimes NSMutableArray mutableCopy overflows.
- NSMutableArray * mutableRecents = [NSMutableArray arrayWithArray: recentSearches];
- // NSMutableArray * mutableRecents = [recentSearches mutableCopy]; memory overflow
- [MutableRecents removeObject: searchString];
- NSMutableArray * mutableRecents = [NSMutableArray arrayWithArray: recentSearches];
- // NSMutableArray * mutableRecents = [recentSearches mutableCopy]; memory overflow
- [MutableRecents removeObject: searchString];
4. Most memory overflow in dealloc is caused by improper initialization of init or initWithFrame.
5: Check the memory overflow with the simulator under the Instrument, and then use the Instrument to connect the real machine.
Summary:IOS Memory OptimizationI hope this article will help you!