0

其基于位置的应用程序和应用程序在 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;

    }
4

0 回答 0