开发者

memory leak in simulator

Instruments show me a leak in simulator in the following code,

UIBarButtonItem *connectButton = [[UIBarButtonItem alloc] initWithTitle:@"Connexion" style:UIBarButtonItemStyleBordered target:self action:@selector(pushViewController)];

    [self.navigationItem setLeftBarButtonItem:connectButton animated:animated];
    [connectButton release];

Do开发者_StackOverflow you see any leak ?? thanks


Leaks is showing you where the object was allocated, not where the object was leaked.

While the two might be the same, it is often much more likely that the leak of an object is caused by an extra retain or missing release somewhere else.


I don't see any leaks in the code you posted. That said, a couple questions:

  1. How do you know that's where the leak is?
  2. Any chance the getter for navigationItem is using copy? If so, there could be a leak there.


...and on device? You should check this on device. There are very, very few situations where you'd want to use the simulator for this kind of testing. It's not representative of how the device itself behaves. I'd recommend you test this on a device, and then if you're still seeing it come back here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜