i am developing the ios app and now want to test it for memory leaks, i have used the
clang static analyzer
and its giving me this bug report
-(void)pass
{
printf("reading plist info");
// Path to the plist (in the application bundle)
NSString *path = [[NSBundle mainBundle] pathForResource:
@"sortednames" ofType:@"plist"];
// Build the array from the plist
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
for (id key in dict) {
NSLog(@"bundle: key=%@, value=%@", key, [dict objectForKey:key]);
string_values=[dict objectForKey:key];
//NSLog(@"bundle data: key=%@, value=%@", key, [string_values objectAtIndex:0]);
}
//[dict release];
}
the info provided by analyzer is
and one things more
is it enough for memory management for my app ????
or i have to do some more tasks ???
thanks for replies
string_values = [[dict objectForKey:key] **retain**];
You should synthetise a strong / retain property and assign your ivar via self.string_values. You can then release your dictionnary and string_value will still be valid.
...
@property(nonatomic, retain)NSString* string_value;
...
@synthetyse string_value;
...
then
self.string_values = [dict objectForKey:key];
And no, static analyzer is not a bullet proof for memory leaks. It can find algorythmically a leaks on compute time, but not those on runtime. That's why it's called static analyzer. But it's really helpful by the way!
You can then profile your apps and use the leaks tool in order to check others leaks.