iOS 4.2操作系统正在调用Zombie的viewDidUnload(未分配的类)

时间:2011-02-28 14:29:35

标签: iphone ios uiviewcontroller uinavigationcontroller nszombie

我有一组UIViewControllers,我与NavigationController堆积在一起。当我到达这一堆的最后一个元素时,我做了一个popToRootViewController。如果我再次尝试创建这个堆(是的,我确实在我的视图中使用了一些内存),系统会在导航控制器堆中为我之前的一个对象调用memoryWarning和viewDidUnload。我知道这没关系,我无法控制何时会生成内存警告或调用viewDidUnload。问题是,由于某些原因,当它到达那里时,'self'已经是未分配的(NSZombie)所以我无法将我的属性设置为nil并释放内存。如果我这样做,我将收到一条发送给已解除分配的实例的消息。

两件事:

(a)当我弹出root用户时,有没有办法强制从navigationcontroller释放所有子视图,这样我可以更“友好”?

(b)为什么要调用未分配类的viewDidUnload?

这是我得到的堆栈跟踪:

#0  0x33a69910 in ___forwarding___ ()
#1  0x33a69860 in __forwarding_prep_0___ ()
#2  0x0000e4a2 in -[MyViewController viewDidUnload] at /Users/Fernando/src/Classes/MyViewController.m:866
#3  0x32105484 in -[UIViewController unloadViewForced:] ()
#4  0x321053d0 in -[UIViewController unloadViewIfReloadable] ()
#5  0x3219ede4 in -[UIViewController purgeMemoryForReason:] ()
#6  0x3219ee04 in -[UIViewController didReceiveMemoryWarning] ()
#7  0x0000e426 in -[MyViewController didReceiveMemoryWarning] ()
#8  0x3219ee1a in -[UIViewController _didReceiveMemoryWarning:] ()
#9  0x3362d622 in _nsnote_callback ()
#10 0x33a47122 in __CFXNotificationPost_old ()
#11 0x33a46dc2 in _CFXNotificationPostNotification ()
#12 0x3361cd22 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#13 0x33626240 in -[NSNotificationCenter postNotificationName:object:] ()
#14 0x32167da8 in -[UIApplication _performMemoryWarning] ()
#15 0x321689ca in -[UIApplication _receivedMemoryNotification] ()
#16 0x32165776 in _memoryStatusChanged ()
#17 0x33a770cc in __CFNotificationCenterDarwinCallBack ()
#18 0x33a5dbe6 in __CFMachPortPerform ()
#19 0x33a556fe in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#20 0x33a556c2 in __CFRunLoopDoSource1 ()
#21 0x33a47f7c in __CFRunLoopRun ()
#22 0x33a47c86 in CFRunLoopRunSpecific ()
#23 0x33a47b8e in CFRunLoopRunInMode ()
#24 0x33b0e4aa in GSEventRunModal ()
#25 0x33b0e556 in GSEventRun ()
#26 0x32099328 in -[UIApplication _run] ()
#27 0x32096e92 in UIApplicationMain ()
#28 0x00002c72 in main at /Users/Fernando/src/main.m:13

非常感谢任何帮助/建议!

谢谢,

费尔南多

1 个答案:

答案 0 :(得分:2)

  

(a)我有办法强迫   从中释放所有子视图   我弹出的导航控制器   因此,我可以更多'记忆   友好'?

可能你可以获取popToRootViewController的返回值并释放它们吗?

  

(b)为什么要调用viewDidUnload   一个未分配的班级?

不确定,如果可能,您可以分享您的代码吗?