开发者

Instruments showing false leak?

I am not sure why Instruments is showing the fol开发者_StackOverflow中文版lowing code as leaking 128 bytes on the UILabel initWithFrame line:

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

Note that in this classes is releasing the emptyMsg property in the following:

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

At one point I wasn't using the accessor method to set emptyMsg so I expected that change to the make this leak go away. Alas, it is still showing up. Can some one point me to another cause?

Declaration of variable:

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


There's nothing wrong with the way you've done it. (Although I would take Rich's advice and not use the dot syntax in the dealloc method; release the instance variables instead.) Instruments shouldn't be confused by it, but Instruments is not perfect. If it is insisting that's a memory leak, it's a false positive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜