objective c - when is the memory released in this function -


i have got view controller calls function in nsobject file.

so in main view controller call function by

[databasefunctions fillarrays: array];

array nsmutablearray initialised in view controller.

in databasefunctions.h

+ (void) fillarrays : (nsmutablearray*) array; 

and in databasefunctions.m

+ (void) mainscreenfill : (nsmutablearray*) array{     sqlite3_stmt *statement;      if (sqlite3_open([dbdatabasepath utf8string], &tabledb)==sqlite_ok) {         [array removeallobjects];          nsstring *querysql = [nsstring stringwithformat:@"select variable, variable1, variable2, variable3 table];         const char* query_sql = [querysql utf8string];          if (sqlite3_prepare(tabledb, query_sql, -1, &statement, null)==sqlite_ok) {             while (sqlite3_step(statement)==sqlite_row)             {                 maintableview *p = [[maintableview alloc]init];                 [p setfirstname:[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 0)]];                 [p setsecondname:[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 1)]];                 [p setclass:[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 2)]];                  [array addobject:p];             }         }     }     sqlite3_close(tabledb); } 

my question when memory allocation maintableview *p = [[maintableview alloc]init]; deallocated?

according apple's docs on memory management:

when retain count becomes zero, object deallocated (destroyed).

in scenario described, variable assigned p not deallocated, since adding array. array maintains strong reference object, , not deallocated until reference broken (until remove object array, or array deallocated).


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -