iPhone上的内存泄漏

时间:2010-08-18 04:18:24

标签: iphone

alt text alt text alt text 嗨,我发现泄漏仪器工具泄漏,但不知道为什么这种方法让我泄漏。任何帮助?代码在下面

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
    // Setup the SQL Statement and compile it for faster access
    NSString *str = [NSString stringWithFormat:@"SELECT UsageData.Date,UsageData.Time,UsageData.NoOfMovementRegistered,UsageData.BreathingRate,UsageData.TimeSinceLastMovement,UsageData.Status,UsageData.bID FROM UsageData INNER JOIN Beds ON UsageData.bID = Beds.bID  WHERE Status = 'Alert' OR Status = 'Unused' GROUP BY UsageData.bID ORDER BY UsageData.bID LIMIT '%d'",[appDelegate.beds count]];
    const char *sqlStatement = [str UTF8String];
    sqlite3_stmt *compiledStatement;

    if(sqlite3_prepare_v2(database, sqlStatement,-1, &compiledStatement, NULL) == SQLITE_OK) {
        // Loop through the results and add them to the feeds array
        while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
            // Read the data from the result row
        //leak  NSString *aDate = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)] ;
        //leak  NSString *aTime = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)] ;
        //leak  NSString *aNoOfMoveReg = [NSString  stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)] ;
        //leak  NSString *aBreathRate = [NSString  stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)] ;
        //leak  NSString *aTimeSinceLastMovement = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)] ;
        //leak  NSString *aStatus = [NSString  stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)] ;
        //leak  NSString *aBID = [NSString  stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 6)] ;

            NSLog(@"aDate %@",aDate);
            NSLog(@"aTime %@",aTime);
            NSLog(@"aNoOfMoveReg %@",aNoOfMoveReg);
            NSLog(@"aBreathRate %@",aBreathRate);
            NSLog(@"aTimeSinceLastMovement %@",aTimeSinceLastMovement);
            NSLog(@"aStatus %@",aStatus);
            NSLog(@"aBID %@",aBID);


            IconUsageData *usagedata = [[IconUsageData alloc] initWithDate:aDate time:aTime noofmovereg:aNoOfMoveReg breathrate:aBreathRate timesincelastmovement:aTimeSinceLastMovement status:aStatus bedid:aBID];
            [appDelegate.iconUsageDatas addObject:usagedata];

            [usagedata release];

            [aDate release];
        }
    }
    // Release the compiled statement from memory
    sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);

*编辑以显示上面的截图

1 个答案:

答案 0 :(得分:0)

在不在上述代码范围内的变量中解决了一个未被释放的变量。