I would appreciate if someone would help me solve my problem. Leaks occur at: aImage, aCategory, aDescription, category and categories. I release them in dealloc, but obviously this is not enough:
-(void) readListFromDatabase:(char *) sqlStatement {
databaseName = @"mydatabase.sql";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
sqlite3 *database;
categories = [[NSMutableArray alloc] init];
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
aImage = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
aCategory = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
category=[[Category alloc] initWithName:aImage category_name:aCategory description_text:aDescription];
[categories addObject:category];
[category release];
}
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}
- (void)dealloc {
[databaseName release];
[databasePath release];
[categories release];
[aImage release];
[aCategory release];
[aDescription release];
[category release];
[super dealloc];
}
source
share