Memory is not freed after you open the viewcontroller using ARC

Hi, my project is based on ARC, I use the UINavigationController to navigate between the ViewController. I use a profiler to analyze what happens behind the scenes with memory. I noticed that when I click ViewController, it allocates memory to all its components, and when I exit, it does not free the allocated memory.

Since I use ARC, I cannot implement dealloc or release any component. I have analyzed in detail, and there is no memory leak in my project.

I do not use a strong property for pushController. This is how I click ViewController.

viewController *obj = [[viewController alloc] init]; [self.navigationController pushViewController:obj animated:NO]; 

Any clue what's going on? what should i do to free the memory i used. Please inform

+4
source share
1 answer

Your description shows that you have a hold cycle, which results in objects not being freed. A typical source of hold cycles are properties assigned by loading NIB files (usually declared as IBOutlet ).

Two strategies to break them down and free objects:

  • Declare the property as weak :

     @property (nonatomic, weak) IBOutlet UILabel *statusLabel; 
  • Set the nil property in viewDidUnload :

     - (void)viewDidUnload { self.statusLabel = nil; [super viewDidUnload]; } 
0
source

Source: https://habr.com/ru/post/1489517/


All Articles