我嘗試做一個應用程序,但我得到了很多崩潰的內存分配,然後我儘量減少所有的代碼,並進行清潔,現在我得到這個電子分配太多的內存
爲什麼我得到:
物體的潛在的泄漏上線101分配並存儲到「livello」
- (id) leggiLivelloDaTabella:(NSString *)tabella {
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *databasePath = [documentsDir stringByAppendingPathComponent:@"DataBase.sqlite"];
sqlite3 *database;
Livello *livello = nil;
if (sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// query che ricava i valori
const char *sql = [[NSString stringWithFormat:@"select * from Livelli WHERE Tabella = '%@'",tabella] UTF8String];
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
// ricaviamo i valori letti dalla query
NSString *nomeTabella = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];
NSString *risposteGiuste = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
NSString *stato = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 2)];
NSString *risposteMinime = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 3)];
NSString *tentativiSbagliati = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 4)];
NSString *tentativiTotali = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 5)];
NSString *popUp = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 6)];
NSString *idLivello = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 7)];
livello = [[Livello alloc] initLivelloWithTabella:nomeTabella
rispGiuste:risposteGiuste
statoLivello:stato
rispMinime:risposteMinime
tentativiSbagliati:tentativiSbagliati
tentativiTot:tentativiTotali
disaplyPopUp:popUp
idLevel:idLivello];
}
}
sqlite3_finalize(selectstmt);
sqlite3_close(database);
selectstmt = nil;
}
else
sqlite3_close(database);
return livello;
}
那麼你是 「黃金」 荷蘭國際集團呢,你在哪裏將其釋放?你有沒有打過[livello發佈]? – trumpetlicks