每次连接到sqlite时,都会创建并保留一个对象,这里是连接到db
的代码+ (void) getInitialDataToDisplay:(NSString *)dbPath :(NSString *)searchtext{
MashahirAppDelegate *appDelegate = (MashahirAppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *cat=[[[NSString alloc]initWithFormat:@"%@%@%@",@"-",[MashahirAppDelegate catid],@"-"]autorelease];
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
NSString *query=[[NSString alloc]initWithFormat:@"select ID, Name from Profile where name like '%@%@%@%@%@",@"%",searchtext,@"%' and ParentCat like '%",cat,@"%' order by name"];
const char *sql = [query UTF8String ];
[query release];
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
MashahirDB *MashahirDBObj = [[MashahirDB alloc] initWithPrimaryKey:primaryKey];
MashahirDBObj.Name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
[appDelegate.MashahirArray addObject:MashahirDBObj];
[MashahirDBObj release];
}
}
sqlite3_finalize(selectstmt);
}
sqlite3_close(database);
}
这是来自乐器的照片: Picture from Instrument http://029.img98.net/out.php/i282779_12121.png
答案 0 :(得分:0)
您链接的图片没有显示任何内存泄漏,这是分配详细信息,您可以正常查看这些分配。