简体   繁体   English

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

[英]iOS 4.2 OS is calling viewDidUnload of a Zombie (unallocated class)

I have a set of UIViewControllers that I pile up with a NavigationController. 我有一组UIViewControllers,我堆积了一个NavigationController。 When I get to the last element of this pile, I do a popToRootViewController. 当我到达这一堆的最后一个元素时,我做了一个popToRootViewController。 If I try to create this pile again (and yes, I do use some load of memory in my views) the system calls a memoryWarning and viewDidUnload for one of my previous objects in the navigationcontroller pile. 如果我再次尝试创建这个堆(是的,我确实在我的视图中使用了一些内存),系统会在导航控制器堆中为我之前的一个对象调用memoryWarning和viewDidUnload。 I know this is ok, I can't control when it will generate memory warnings or call viewDidUnload. 我知道这没关系,我无法控制何时会生成内存警告或调用viewDidUnload。 The problem is that for some reason when it gets there 'self' is already unallocated (NSZombie) so I can't set my properties to nil and release memory. 问题是,由于某些原因,当它到达那里时,'self'已经是未分配的(NSZombie)所以我无法将我的属性设置为nil并释放内存。 If I do I'll get a message sent to deallocated instance. 如果我这样做,我将收到一条消息发送到解除分配的实例。

Two things: 两件事情:

(a) Is there a way for me to force releasing all subviews from navigationcontroller when I pop to root so I can be more 'memory friendly'? (a)当我弹出root用户时,有没有办法强制从navigationcontroller释放所有子视图,这样我可以更“友好”?

(b) Why would it call viewDidUnload of an unallocated class? (b)为什么要调用未分配类的viewDidUnload?

Here is the stack trace I get: 这是我得到的堆栈跟踪:

#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

Any help/suggestion is really appreciated! 任何帮助/建议真的很感激!

Thanks, 谢谢,

Fernando 费尔南多

(a) Is there a way for me to force releasing all subviews from navigationcontroller when I pop to root so I can be more 'memory friendly'? (a)当我弹出root用户时,有没有办法强制从navigationcontroller释放所有子视图,这样我可以更“友好”?

May be you can grab the return value of the popToRootViewController and release them ? 可能你可以获取popToRootViewController的返回值并释放它们吗?

(b) Why would it call viewDidUnload of an unallocated class? (b)为什么要调用未分配类的viewDidUnload?

Not sure, can you share your code if possible? 不确定,如果可能的话,你能分享你的代码吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM