这个短函数中的内存泄漏
为什么这段代码会产生内存泄漏?
- (void)loadModalInfo
{
InformationScreenViewController *infoView = [[InformationScreenViewController alloc] init];
infoView.url = [[NSBundle mainBundle] URLForResource:@"NewPatientInfo" withExtension:@"html"]; // LEAKING
// [infoView setModalPresentationStyle:UIModalPresentationFormSheet];
[infoView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:infoView animated:YES];
[infoView release];
infoView = nil;
}
我是 Instruments 的新手,我不明白为什么代码会泄漏。 提前致谢。
Why is this code producing a memory leak?
- (void)loadModalInfo
{
InformationScreenViewController *infoView = [[InformationScreenViewController alloc] init];
infoView.url = [[NSBundle mainBundle] URLForResource:@"NewPatientInfo" withExtension:@"html"]; // LEAKING
// [infoView setModalPresentationStyle:UIModalPresentationFormSheet];
[infoView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:infoView animated:YES];
[infoView release];
infoView = nil;
}
I'm new using Instruments and I can't figure out why is that code leaking.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
InformationScreenViewController.m
的dealoc
方法中释放 url。In your
InformationScreenViewController.m
in thedealoc
method release the url.