I am using Objective C with ARC. I have the following snippet of code, which seems to leak memory due to the string formatter.
I changed the stringWithFormat
convenience method into the more general alloc init
, but it still leaks memory in this line.
I read here that I should use the copy
keyword, but it still leaks memory in this line.
Now, when I remove the formatter altogether, the code does not leak memory in this line.
- Why is this line causing a memory leak?
- How can I solve this memory leak?
Additional information:
- Code written in: Xcode 6.3.1
- Memory leaks visualized using: Instruments from Xcode 6.3.1
- iOS Deployment Target: iOS 5.0
Code base:
#define DATABASE_NAME @"orderwriter"
+ (SQLiteManager *) getSQLiteManager
{
// NSInteger userId = [(NSString *)[AppUtil NSDefaultforKey:USER_ID] integerValue];
// NSString *dbName = [NSString stringWithFormat:@"%@_%ld.db", DATABASE_NAME, (long)userId];
NSString *dbName = @"orderwriter_58.db";
SQLiteManager *dbManager = [[SQLiteManager alloc] initWithDatabaseNamed:dbName];
return dbManager;
}
The class SQLiteManager
, I found here on Github.
DATABASE_NAME
so again the code can't be tested. – zaph