如何解决我已经看到3个函数的严重泄漏,我一次又一次调用这些函数
| 我一次又一次使用3个函数,但每次都会看到泄漏。这些泄漏的原因是什么?//function 1
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = appDelegate.Date_iCal;
localNotification.alertBody = appDelegate.Name;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = count;//total number of event in iCal
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@\"Object 1\",@\"Key 1\",@\"Object 2\",@\"Key 2\",nil];
localNotification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release] ;
//Local notification add
function2:
EKEventStore *eventStore = [[EKEventStore alloc]init] ;
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = appDelegate.Name;
event.startDate = appDelegate.Date_iCal;
event.endDate = appDelegate.Date_iCal;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
@try
{
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
NSString* str = [[NSString alloc] initWithFormat:@\"%@\",event.eventIdentifier];
appDelegate.eventIdentifier = str;
[str release];
}
@catch (NSException * e)
{
//NSLog(@\"exeption run1\");
}
[eventStore release];
//function3
int flag1 = 0;
if( [appDelegate.display_date length] == 0 || [appDelegate.timestamp1 length] == 0)
{
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@\"dd.MM.yyyy hh:mm a\"];
appDelegate.display_date = [df stringFromDate:[NSDate date]];
appDelegate.timestamp1 = @\"empty\";
[df release];
}
addStmt1 = nil;
if(addStmt1 == nil)
{
const char *sql =\"insert into actions(action_title,action_date,dificulty_level,subid,flag,needle_num,display_date,event) Values(?,?,?)\";
if(sqlite3_prepare_v2(database1,sql,-1,&addStmt1,NULL) != SQLITE_OK)
NSAssert1(0,@\"Error while creating add statement. \'%s\'\",sqlite3_errmsg(database1));
}
sqlite3_bind_text(addStmt1,1,[appDelegate.Name UTF8String],SQLITE_TRANSIENT);
sqlite3_bind_text(addStmt1,2,[appDelegate.timestamp1 UTF8String],SQLITE_TRANSIENT);
sqlite3_bind_double(addStmt1,3,appDelegate.dif_lev);
sqlite3_bind_int(addStmt1,4,(int)appDelegate.Id);
sqlite3_bind_int(addStmt1,5,flag1);
sqlite3_bind_int(addStmt1,6,(int)appDelegate.needle_num);
sqlite3_bind_text(addStmt1,7,[appDelegate.display_date UTF8String],8,[appDelegate.eventIdentifier UTF8String],SQLITE_TRANSIENT);
if(SQLITE_DONE != sqlite3_step(addStmt1))
{
@try
{
NSAssert1(0,@\"Error while inserting data. \'%s\'\",sqlite3_errmsg(database1));
}
@catch (NSException * e)
{
//NSLog(@\"exeption run3\");
}
}
sqlite3_reset(addStmt1);
sqlite3_finalize(addStmt1);
if( [appDelegate.display_date isEqualToString:@\"empty\"])
appDelegate.display_date = @\"\";
我要去哪里错了?
这些功能一键运行。
解决方法
清理您的应用程序,然后按Command + A,这将运行仪器,并向您显示所有泄漏。
正如您所说的那样,有3个泄漏,所以这意味着您已按照上述步骤进行操作。
现在,正确地阅读泄漏,您将得到发生泄漏的那条线的原因。
请检查一下。
快乐的iCoding ...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。