Instruments-Xcode-Leaks=> [UIImage imageWithData:]
刚开始使用 Instruments,但认为这有助于提高我正在开发的应用程序的性能。我在以下命令中遇到错误泄漏,并且想知道这是否是我做错的事情,或者我实际上可以取消分配它。
基础 - 加载 UITableView - 使用 JSONDeserializer 解析数据并将其推送到 NSDictionary 中。文本标签没有泄漏,是我的 UIImage 发生泄漏。 (每个表格单元格有 1 个图像,通过 JSONDeserizer 加载,该图像具有有效的链接 (http),图片被下载,然后显示在该特定单元格中
这是编码......
cell.myImageView.image = [[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:[dict objectForKey:@"picture"]]]] retain];
任何帮助将不胜感激... 谢谢 :-)
New to using Instruments, but figured it would be good to help the performace of my application I am developing. I am getting Error leaks on the following command, and was wondering if it might be something I am doing wrong, or can I actually deallocate this.
BASICS - a UITableView is loaded - using JSONDeserializer the data is parsed and pushed into a NSDictionary. the text labels have no leaks, it's my UIImage that is having the leak. (Each tablecell has 1 image, that is loaded through JSONDeserizer that has a valid link (http) for the picture, and the picture is downloaded and then displayed in that specific cell
Here is the coding....
cell.myImageView.image = [[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:[dict objectForKey:@"picture"]]]] retain];
any help would greatly be appreciated... thanks :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要保留使用
imageWithData
返回的对象,因为分配会为您保留该对象。仪器显示由于额外的保留计数增量而导致泄漏。删除保留,一切都应该没问题。
You don't need to retain the object returned with
imageWithData
since the assignment does the retention for you.Instruments are showing you leak because of that extra retain count increment. Remove the retain and all should be fine.