I’m new in iphone dev and in the deal of the memory issues.
I’m learning but some things remain mysterious for me.
In the following case, the leaks analyzer of “Instruments” says I have a leak in the databasePath setting. I can’t figure out why.
// databaseName and databasePath are properties of my class.
databaseName = [[NSString alloc] initWithString:@"sqlDbName.sql"];
NSArray *documentPaths = [[NSArray alloc] initWithArray:NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)];
NSString *documentsDir = [[NSString alloc] initWithString:[documentPaths objectAtIndex:0]];
// The problem is here :
databasePath = [[NSString alloc] initWithString:[documentsDir stringByAppendingPathComponent:databaseName]];
[documentPaths release];
[documentsDir release];
I release databaseName and databasePath later in the dealloc.
Your help will be very appreciate !
Is there any possibility that this code is executing more than once. You have released
databasePathindealloc. In case this code is executed more than once thendatabasePathwill leak for any successive execution.