iOS 分配 - 堆快照中的持久计数并不总是 0
在分析我的 iOS 应用程序时,我多次执行一个简单的任务,从堆栈中推送和弹出视图,然后进行堆快照。每次都会执行相同的代码,推送的视图只包含一些图像,一旦视图弹出,这些图像就会被删除。
现在,由于几乎一半的堆快照的持久计数为 0,是否可以安全地假设没有被遗弃的记忆?
我听说持久计数大于零的行可能是由于某些内部缓存造成的。
我正在使用 Xcode 4.2.1 并且该应用程序正在使用 ARC。
编辑:
感谢 Kendall Helmstetter Gelner,我已经成功地进一步调试了这个问题。我可能不应该使用模拟器来调试它。我现在已经在设备上运行它,现在看起来有一个对象没有被释放:
查看扩展详细视图后,我想我已经找到了问题的原因。
While profiling my iOS app I perform a simple task multiple times where I push and pop a view from the stack, and then take a heapshot. The same code is executed each time and the pushed view just contains some images which get removed as soon as the view gets popped.
Now because the persistent count is 0 for almost half of the heapshots, would it be safe to assume there is no abandoned memory?
I've heard that the rows with a persistent count greater than zero could be because of some internal caching.
I am using Xcode 4.2.1 and the app is using ARC.
Edit:
Thanks to Kendall Helmstetter Gelner I've managed to debug this problem further. I probably shouldn't have been using the simulator for debugging this. I've now run it on the device and it now looks like there is one object which isn't getting released:
After looking through the extended detail view I think I've just about found the cause of the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅从该屏幕截图中很难判断哪些内容可能被缓存或不被缓存 - UIImage 会缓存内容,也可能缓存一些其他系统元素。看起来您可能正在模拟器中运行它,您是否在设备上尝试过 heapshot ?
您还可以选择旁边的“隐藏系统库”,并更好地了解涉及您自己的代码量。
It's hard to say from just that screenshot what might be cached or not - UIImage will cache things, possibly some other system elements too. It looks like you might be running that in the simulator, have you tried heapshot on a device?
You could also select "Hide System Libraries" to the side and get a better idea how much of your own code is involved.