开发者

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. When I get to the last element of this pile, I do a 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. I know this is ok, I can't control when it will generate memory warnings or call 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. 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'?

(b) Why would it call viewDidUnload of an unallocated class?

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开发者_JS百科 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'?

May be you can grab the return value of the popToRootViewController and release them ?

(b) Why would it call viewDidUnload of an unallocated class?

Not sure, can you share your code if possible?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜