@zoeb, this link will help you avoid problems with main memory.
ways to overcome memory-in-iphone problems with automatic link counting
Edited by:
As you know, Apple introduced ARC in iOS 5.0, ARC is a compiler-level function that simplifies the life process of objective-c objects. Before introducing ARC, we managed the memory manually - Manual Reference Counting (MRC). In MRC, a developer needs to remember when to release or save an object. This means that the developer needs to manage the life cycle of objective-c objects.
In accordance with the developer's perspective, we are mainly interested in adding new features to our application, and not in solving memory problems. But everyone is confident that memory management plays a crucial role in the success of the application. To provide assistance to the developer, Apple has figured out a way to automatically manage memory.
ARC skillfully manages memory, but it's not 100 percent. We need to focus on some development points to remove our application due to lack of memory. Here I will try to provide a memory management solution in a basic ARC application. which is not 100 percent. but he will try to help the compiler evaluate the life cycle of an object.
Here are some steps you need to implement in each controller.
Step 1. Declare a weak property for each user interface control that is used in the application.
Example:
@property (nonatomic, weak) IBOutlet UIButton* btnPost;
@property (nonatomic, weak) IBOutlet UITableView* tblMessages;
and etc.
Step 2 .. According to our developer, the most confusing question is whether the compiler allows the dealloc method to be declared in the underlying ARC application. The answer is yes, but it is not allowed to declare "[super dealloc]" inside it. therefore, override the "dealloc" method in each controller.
-(void)dealloc{ }
Step 3. Remove the heavily loaded object from the supervisor in the "dealloc" method, and then set only the "null" link, such as MKMapview, ScrollView, etc.
-(void)dealloc{ dictAddress = nil; arrayList = nil; [map removeFromSuperview]; [scrollView removeFromSuperview]; }
Step 4. Avoid the locking mechanism. (Example: class A and class B. Class B is declared as a delegate with the property type Strong, so class A and class B, which are dependent on each other on one, will be released, so in this case the dealloc method is not called by any from classes, so this class is stored in memory. To remove such cases, we need to save the "Assign" link for the Delegate object.) This, for example, is only. We need to consider other things, such as "Keep a weak link for the block so that it frees objects after completion."
These are the basic steps to avoid memory problems. However, if you run into memory problems, you need to use the Analyzer help to find the memory leak and usage.
The link below will help you analyze memory.
Mamory Analyzer