I'm having a problem with a view controller that's dismissed and not referenced but still in memory, just wondering in general when is the object actually released in memory when no one references it?
我遇到了一个视图控制器的问题,该视图控制器被解雇但未被引用但仍在内存中,只是想知道当没有人引用时,实际上在内存中释放的对象是什么时候?
The way I used to test is that I installed the PVC tool from Facebook and use it to print out the view hierarchy when the view controller is presented, after it's dismissed, I make sure no one's referencing it and paused the execution so I can po
the memory address of the view controller from the previous PVC tool, but I can still see the view controller instance there.
我以前测试的方式是我从Facebook安装了PVC工具,并在显示视图控制器时使用它打印视图层次结构,在它被解除后,我确保没有人引用它并暂停执行所以我可以po来自以前的PVC工具的视图控制器的内存地址,但我仍然可以在那里看到视图控制器实例。
Thanks!
谢谢!
1 个解决方案
#1
2
You appear to be confusing being released and being cleared from memory. When the class is destroyed, the memory it occupied is not zeroed, just like when you delete a file in the filesystem, the disk blocks are not zeroed either.
你似乎很困惑被释放并从内存中清除。当类被销毁时,它占用的内存不会归零,就像删除文件系统中的文件一样,磁盘块也不会归零。
This would simply take up too much time and have very little benefit.
这只会占用太多时间而且收效甚微。
Being released simply means the memory the class occupied can now be re-used.
被释放只是意味着现在可以重复使用该类所占用的内存。
One way to see if the class has been destroyed is to add a log in the dealloc
method:
查看类是否已被销毁的一种方法是在dealloc方法中添加一个日志:
- (void)dealloc
{
NSLog(@"I'm being destroyed");
}
#1
2
You appear to be confusing being released and being cleared from memory. When the class is destroyed, the memory it occupied is not zeroed, just like when you delete a file in the filesystem, the disk blocks are not zeroed either.
你似乎很困惑被释放并从内存中清除。当类被销毁时,它占用的内存不会归零,就像删除文件系统中的文件一样,磁盘块也不会归零。
This would simply take up too much time and have very little benefit.
这只会占用太多时间而且收效甚微。
Being released simply means the memory the class occupied can now be re-used.
被释放只是意味着现在可以重复使用该类所占用的内存。
One way to see if the class has been destroyed is to add a log in the dealloc
method:
查看类是否已被销毁的一种方法是在dealloc方法中添加一个日志:
- (void)dealloc
{
NSLog(@"I'm being destroyed");
}