I have simple code that inserts values into my database:
-(void)inserirBd:(NSString *)valores{
sqlite3_stmt *statement;
// Get the documents directory
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = dirPaths[0];
// Build the path to the database file
databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent:@"fazerbem.sqlite"]];
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &myDatabase) == SQLITE_OK) {
NSString *insertSQL = valores;
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(myDatabase, insert_stmt,
-1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE) {
} else {
NSLog(@"Error -> %s", sqlite3_errmsg(myDatabase));
}
sqlite3_finalize(statement);
sqlite3_close(myDatabase);
}
}
and I am calling this function in this way:
cInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_products (value) Values ('%@')", p1_1.text,];
InsertBD *insert = [[InsertBD alloc] init];
[insert inserirBd:cInsert];
To perform some tests of memory, I put the above command in a loop that will insert a repeat this 85,000 times, in debug memory, before inserting the values into the database the memory was 1.1 MB, after performing the loop the memory rose to around 500 MB.
But after that, why not the memory lowered to 1.1 MB again? since the loop was already processed and in this case the memory should be released ? (I'm using ARC, and my app only have a button to do this)