1
votes

running my app through Instruments "Leaks" it's saying I've got a leak which seems to happen with this code -

-(void)podAppears {

podCount ++;

NSString *podName = [NSString stringWithFormat:@"Pod%i",podCount];
Pod *thePod = [[Pod alloc] initWithOwner:self withName:podName];

[pods setObject:thePod forKey:podName];
[thePod release];

}

I can't see anything wrong, but I'm fairly new to Objective-C & memory management in general. Any help much appreciated!

1
what is pods? NSDictionary? Also, looks like Pod is a custom class. How about showing us the initWithOwner:withName: method? - jakev
This block looks fine to me, are you sure this is where the leak is? Is this block of code ran off the main thread? - Chris Wagner

1 Answers

0
votes

That code looks fine. When Instruments informs you of a leak, it tells you where the leaked object originated. It's likely that the actual leaking of that object is occurring elsewhere in your app. You should look at other locations where you access your Pod objects.