False Leak Tools?

I'm not sure why the Tools shows the following code as leaking 128 bytes in the UILabel initWithFrame init string:

self.navigationItem.leftBarButtonItem = self.editButtonItem; 
UILabel *tmp = [[UILabel alloc] initWithFrame:CGRectMake(25, 100, 275, 100)];
self.emptyMsg = tmp;
[tmp release];

      

Note that this class disposes of the emptyMsg property in the following:

-(void) dealloc {
     [self.emptyMsg release];
     [self.pathToUsersFriendsFile release];
     [super dealloc];
}

      

At some point I didn't use the accessor method to set emptyMsg, so I expected this change to disappear. Alas, it still appears. Can anyone point me to another reason?

Variable declaration:

@interface FriendListViewController : UITableViewController <AddFriendDelegate> {
    NSString *pathToUsersFriendsFile;
    UILabel *emptyMsg;
}
@property(retain) UILabel *emptyMsg;
@end

      

+2


source to share


1 answer


There is nothing wrong with the way you did it. (Though I would take Rich's advice and not use the dot syntax in the method dealloc

; issue instance variables instead). Tools should not be confused with this, but tools are not perfect. If it insists on a memory leak, that's a false positive.



+1


source







All Articles