Memory leak issue in navigation controller

2019-09-04 17:16发布

问题:

I am doing memory leak testing. The tool indicates a leak in line 2 of the code below. What is the reason?

DailySales *ds = [[DailySales alloc] initWithNibName:@"DailySales" bundle:nil];
[self.navigationController pushViewController:ds animated:YES];
[ds release];

回答1:

The code looks fine. Are you running in the simulator or on the device? Running Instruments on the simulator can produce false leak reports.



回答2:

Objects loaded from the NIB are leaking. Check your outlets and see if they are carefully released in dealloc.