我已经看到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 ...     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...