Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory Leak when returning NSMutableDictionary object
    text
    copied!<p>I have memory leaks in the aTierOneData and when i tried [aTierOneData autorelease] , my app crashed.so how i can fix this memory leak.</p> <p>Plese let me know </p> <pre><code>//=============================================================== - ( NSMutableDictionary * ) getDataToDisplayTierOne:(NSString*)dbPath{ //================================================================ NSMutableDictionary *aTierOneData = [[NSMutableDictionary alloc]init]; if (sqlite3_open([dbPath UTF8String], &amp;database) == SQLITE_OK) { const char *sql_query_stmt = "select * from main_categories"; sqlite3_stmt *selectstmt; if(sqlite3_prepare_v2(database, sql_query_stmt, -1, &amp;selectstmt, NULL) == SQLITE_OK) { while(sqlite3_step(selectstmt) == SQLITE_ROW) { NSString *aValue = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(selectstmt, 1)]; NSString *aId = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(selectstmt, 0)]; [aTierOneData setObject:aId forKey:aValue]; [aValue release]; [aId release]; } } } else{//Even though the open call failed, close the database connection to sqlite3_close(database); } return aTierOneData; } -(void)fetchDataForTierOne{ //=========================== myTierOneDict = [[NSMutableDictionary alloc]init]; myTierOneDict = [myDBOperations getDataToDisplayTierOne:[appDelegate getDBPath]]; NSArray *myTierOneDictKeys = [myTierOneDict allKeys]; myTierOneData = [[NSMutableArray alloc] initWithArray:(NSArray*)myTierOneDictKeys]; if ([myTierOneData count] &gt; 0 ){ [self constructTierOnePicker]; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload