【发布时间】:2011-06-30 06:20:36
【问题描述】:
我有一个父表视图控制器,上面有一个只读的详细视图控制器属性,它懒惰地实例化详细视图控制器。如果我在 iphone/ipod 上,我会在选择表中的项目时配置并推送详细视图控制器。当细节视图可见并且我在导航控制器中单击两次时,细节控制器然后父控制器被弹出并调用父级的dealloc。当父级的 dealloc 到达我调用 [detailViewController release] 的行时,我从导航控制器中遇到 EXC_BAD_ACCESS 崩溃。这让我认为我的问题在于 detailViewController 的内存管理,但使用 NSZombies 进行调试没有问题。 (注释掉 [detailViewController release] 行会使崩溃消失,但是我从来没有发布来平衡 detailViewController 的分配——内存泄漏)任何想法为什么我会发生这种崩溃?
编辑: 这是崩溃的堆栈跟踪:
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x01046a63 in objc_msgSend ()
#1 0x0a9d72a0 in ?? ()
#2 0x0000cb4c in -[MyTableViewController dealloc] (self=0xa956840, _cmd=0x127a9d6) at /Users/nick/Documents/MyApp/Classes/MyTableViewController.m:290
#3 0x00390f1d in -[UINavigationController setDisappearingViewController:] ()
#4 0x0038e4f6 in -[UINavigationController _clearLastOperation] ()
#5 0x0038ee3f in -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] ()
#6 0x0051be23 in -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] ()
#7 0x0051cfd2 in -[UINavigationTransitionView _cleanupTransition] ()
#8 0x00308665 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] ()
#9 0x003084f7 in -[UIViewAnimationState animationDidStop:finished:] ()
#10 0x0200c6cb in run_animation_callbacks ()
#11 0x0200c589 in CA::timer_callback ()
#12 0x01225fe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#13 0x01227594 in __CFRunLoopDoTimer ()
#14 0x01183cc9 in __CFRunLoopRun ()
#15 0x01183240 in CFRunLoopRunSpecific ()
#16 0x01183161 in CFRunLoopRunInMode ()
#17 0x01a5a268 in GSEventRunModal ()
#18 0x01a5a32d in GSEventRun ()
#19 0x002e642e in UIApplicationMain ()
#20 0x00001b28 in main (argc=1, argv=0xbffff070) at /Users/nick/Documents/MyApp/main.m:14
编辑2: 崩溃发生的dealloc方法:
- (void)dealloc
{
[context release]; // a managed object context -- when table entries are selected, they get cached in core data
[tableDataArray release];
[detailViewController release]; // <-- line 290, this is where it crashes
[super dealloc];
}
【问题讨论】:
标签: ios exc-bad-access