简体   繁体   中英

pushviewcontroller causing memory leak in ARC

I am really surprised that instruments shows memory leak at pushviewcontroller in my code while I am having ARC enabled in my code. Following is my code:

AddCallDetailsViewController *lAddCallDetailsViewController=[[AddCallDetailsViewController alloc]init];
lAddCallDetailsViewController.isAllDay = isAllDay;
lAddCallDetailsViewController.delegate = self;
lAddCallDetailsViewController.currentDayinCalender = curdate;
lAddCallDetailsViewController.isFromEditCall = YES;
[self.navigationController pushViewController:lAddCallDetailsViewController animated:YES];

And following is the backtrace of instruments that shows 100% leak at that point.

Any help in removing this issue will be highly appreciated.

在此处输入图片说明

Just Try to increase the scope of "lAddCallDetailsViewController" To class level.. In .h file or private scope in .m file.

AddCallDetailsViewController *lAddCallDetailsViewController;

In .m file

lAddCallDetailsViewController=[[AddCallDetailsViewController alloc]init];
lAddCallDetailsViewController.isAllDay = isAllDay;
lAddCallDetailsViewController.delegate = self;
lAddCallDetailsViewController.currentDayinCalender = curdate;
lAddCallDetailsViewController.isFromEditCall = YES;
[self.navigationController pushViewController:lAddCallDetailsViewController animated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM