I use ARC. I find the memory increase constantly.
in .h file
@property (weak, nonatomic) IBOutlet UILabel* contentALabel;
@property (weak, nonatomic) IBOutlet UILabel* contentBLabel;
in .m file
-(void)refreshContent:(NSInteger) itemID
{
sqlite3 *database;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString* databasePath = [docsPath stringByAppendingPathComponent: @"Database.sqlite"];
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
NSString *sql = [NSString stringWithFormat:@"select contentA,contentB from tableA where itemID = %d ",itemID,nil];
char *sqlStatement = (char *)[sql cStringUsingEncoding:NSASCIIStringEncoding];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *contentA = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
NSString *contentB = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
contentALabel.text = contentA;
contentBLabel.text = contentB;
}
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}
I call this function constantly , I find my memory increase as well in the 'Profile' window 'Living Bytes' column.
but if I comment
contentALabel.text = contentA;
contentBLabel.text = contentB;
the memory won't increase any more.
What's wrong with the 'Label.text' ?