ios中sqlite3中的内存泄漏

时间:2012-07-16 06:31:59

标签: objective-c ios memory-management sqlite

基于位置的应用程序和应用程序在5-6之后崩溃   分钟。当我使用性能工具运行应用程序时,泄漏,我保持   发现我的所有类都泄漏了内存。我在说这个   功能逐秒。请正确关闭我的数据库或   sqlite3的。感谢。

 - (void)locationUpdate:(CLLocation *)location {



            for (int i=0; i<[arrayAlerts count]; i++) {
                   Msg=[DatabaseManager GetSelectedMessage:[NSString stringWithFormat:@"select text_msg  from TextMsgTemplate  where msg_id=%d",ObjAlertInfo.msgID]];
        }

    in Databasemanger

    +(NSString *)GetSelectedMessage:(NSString *)SQL
    {

        NSString *msg;//=[[[NSString alloc]init] autorelease];
        msg=nil;
        sqlite3_stmt *dataset=nil; 
        dataset=[DatabaseManager getMessages:SQL];

        while ((sqlite3_step(dataset)==SQLITE_ROW) ) {
            msg=[NSString stringWithUTF8String:(char *)sqlite3_column_text(dataset, 0)];

        } 

        sqlite3_finalize(dataset);

        dataset = nil;
       return msg;

    }


    +(sqlite3_stmt *)getMessages:(NSString *)SQL
    {

        sqlite3_stmt *dataset=nil;

        sqlite3_stmt *finaldataset=nil;

        if (sqlite3_open([[self getdatabasePath] UTF8String], &database) == SQLITE_OK ) {


            if (sqlite3_prepare_v2(database, [SQL UTF8String], -1, &dataset, NULL) != SQLITE_OK) 
            {
                NSLog(@"error get message");
                return nil;

            }else{
                finaldataset= dataset;  

            }

       }

        sqlite3_close(database);

        return finaldataset;

    }

0 个答案:

没有答案