xCode4设置NSZombieEnabled
来源:互联网 发布:淘宝导航栏 编辑:程序博客网 时间:2024/06/02 07:35
今天看到偶然间看到一篇blog,“用NSZombieEnabled解决恼人的EXC_BAD_ACCESS错误”。
很实用的技巧,便拿来试验一下。
原文是在XCode3里面设置的,so在4里面完全找不到地方。stackoverflow搜一下,找到如下方法。
菜单里Product->EditScheme->Run->EnvironmentVariables, 添加NSZombieEnabled,YES。
顺便发现方法2,Product->按住alt/option+鼠标点"Run...",之后同上。
如果你和我一样操作了,一定发现了:按下alt/option键之后菜单边了,同理,按下Ctrl键之后菜单也变了。
神奇ing!
顺便在Navigate看到一条”Fix nextissue“,(按住Ctrl),原来XCode支持自动修复简单错误。
试验发现只要报错信息里有fix方法的,都能用Ctrl+Command+'修复。
In the Xcode IDE two environment variables are useful for gettingfurther information on the memory allocation error EXC_BAD_ACCESSwhen using the simulator:
There variables should be unchecked when not debugging specificmemory issues, as they will cause the memory shortages in theruntime environment, and should never be enabled in a shippingapplication. This is indicated by the followingmessage:
"Data Formatters temporarily unavailable, will re-try after a'continue'. (Not safe to call dlopen at thistime.)"
Uncheck these environment variables to resolve the issue.
NSZombieEnabled=YESMallocStackLoggingNoCompact=1
There variables should be unchecked when not debugging specificmemory issues, as they will cause the memory shortages in theruntime environment, and should never be enabled in a shippingapplication. This is indicated by the followingmessage:
"Data Formatters temporarily unavailable, will re-try after a'continue'. (Not safe to call dlopen at thistime.)"
Uncheck these environment variables to resolve the issue.
Resolution
To set these environment variables in the XcodeIDE.
In Xcode 3.2:
- In the left pane of XcodeexpandExecutables
- Select the application executable
-SelectFile | GetInfo
- SelecttheArguments segmentcontrol
- At the bottom of theVariables to be setin the environment dialogueclick +
-EnterNSZombieEnable forthe nameand YES for thevalue
-Click+ again
-EnterMallocStackLoggingNoCompact forthe nameand 1 for thevalue
- Close the dialogue
In Xcode 4.0:
-SelectProduct | EditScheme from themenu
- Select the appropriate scheme (Run/Test) in theleft pane
- SelecttheArguments segmentcontrol
- At the bottom of theEnvironmentVariables dialogueclick +
-EnterNSZombieEnable forthe nameand YES for thevalue
-Click+ again
-EnterMallocStackLoggingNoCompact forthe nameand 1 for thevalue
- Close the dialogue
Recreate the fault. An error should appear in the debugger console(Run| Console).
This address is then used to query the debuggerwithinfomalloc-history:
That will produce the following output:
The cause of this error is visible near the top of theblock:
In Xcode 3.2:
- In the left pane of Xcodeexpand
- Select the application executable
-Select
- Selectthe
- At the bottom of the
-Enter
-Click
-Enter
- Close the dialogue
In Xcode 4.0:
-Select
- Select the appropriate scheme (Run/Test) in theleft pane
- Selectthe
- At the bottom of the
-Enter
-Click
-Enter
- Close the dialogue
Recreate the fault. An error should appear in the debugger console(Run
*** -[__NSArrayI release]: message sent to deallocated instance 0x4d90af0
This address is then used to query the debuggerwith
(gdb) info malloc-history 0x4d90af0 (注:只能在模拟器上使用)
That will produce the following output:
Alloc: Block address: 0x04d90af0 length: 32Stack - pthread: 0xa0078540 number of frames: 37 0: 0x90e5a103 in malloc_zone_calloc 1: 0x5d862 in NSAllocateScannedUncollectable 2: 0xa659b in _NSInitializeCacheLine 3: 0xa6318 in _sortedObjectsUsingDescriptors 4: 0x127c89 in -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:] 5: 0x24b0d in -[Task getFullSession:intoArray:] at /Application/Task.m:177 6: 0x604d in -[AViewController viewDidLoad] at /Application/Classes/AViewController.m:50 7: 0x3a965e in -[UIViewController view] 8: 0x3a7a57 in -[UIViewController contentScrollView] 9: 0x3b8201 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] 10: 0x3b6831 in -[UINavigationController _layoutViewController:] 11: 0x3b7b4c in -[UINavigationController _startTransition:fromViewController:toViewController:] 12: 0x3b2606 in -[UINavigationController _startDeferredTransitionIfNeeded] 13: 0x4cae01 in -[UILayoutContainerView layoutSubviews] 14: 0x1e87451 in -[CALayer layoutSublayers] 15: 0x1e8717c in CALayerLayoutIfNeeded 16: 0x1e87088 in -[CALayer layoutIfNeeded] 17: 0x3aab5f in -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] 18: 0x3238e9 in -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] 19: 0x5a2948 in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] 20: 0x3ad982 in -[UIViewController presentModalViewController:withTransition:] 21: 0x3a6269 in -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] 22: 0x3ad085 in -[UIViewController presentModalViewController:withTransition:] 23: 0x4bc0 in -[RootViewController tableView:didSelectRowAtIndexPath:] at /Application/Classes/RootViewController.m:98 24: 0x371794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] 25: 0x367d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] 26: 0x7a7f6 in __NSFireDelayedPerform 27: 0x128afe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ 28: 0x128c594 in __CFRunLoopDoTimer 29: 0x11e8cc9 in __CFRunLoopRun 30: 0x11e8240 in CFRunLoopRunSpecific 31: 0x11e8161 in CFRunLoopRunInMode 32: 0x1ae9268 in GSEventRunModal 33: 0x1ae932d in GSEventRun 34: 0x30a42e in UIApplicationMain 35: 0x2914 in main at /Application/main.m:14 36: 0x28a5 in startDealloc: Block address: 0x04d90af0Stack - pthread: 0xa0078540 number of frames: 35 0: 0x90e5e1ad in malloc_zone_free 1: 0xa64bb in _sortedObjectsUsingDescriptors 2: 0x127c89 in -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:] 3: 0x24b0d in -[Task getFullSession:intoArray:] at /Application/Task.m:177 4: 0x604d in -[AViewController viewDidLoad] at /Application/Classes/AViewController.m:50 5: 0x3a965e in -[UIViewController view] 6: 0x3a7a57 in -[UIViewController contentScrollView] 7: 0x3b8201 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] 8: 0x3b6831 in -[UINavigationController _layoutViewController:] 9: 0x3b7b4c in -[UINavigationController _startTransition:fromViewController:toViewController:] 10: 0x3b2606 in -[UINavigationController _startDeferredTransitionIfNeeded] 11: 0x4cae01 in -[UILayoutContainerView layoutSubviews] 12: 0x1e87451 in -[CALayer layoutSublayers] 13: 0x1e8717c in CALayerLayoutIfNeeded 14: 0x1e87088 in -[CALayer layoutIfNeeded] 15: 0x3aab5f in -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] 16: 0x3238e9 in -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] 17: 0x5a2948 in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] 18: 0x3ad982 in -[UIViewController presentModalViewController:withTransition:] 19: 0x3a6269 in -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] 20: 0x3ad085 in -[UIViewController presentModalViewController:withTransition:] 21: 0x4bc0 in -[RootViewController tableView:didSelectRowAtIndexPath:] at /Application/Classes/RootViewController.m:98 22: 0x371794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] 23: 0x367d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] 24: 0x7a7f6 in __NSFireDelayedPerform 25: 0x128afe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ 26: 0x128c594 in __CFRunLoopDoTimer 27: 0x11e8cc9 in __CFRunLoopRun 28: 0x11e8240 in CFRunLoopRunSpecific 29: 0x11e8161 in CFRunLoopRunInMode 30: 0x1ae9268 in GSEventRunModal 31: 0x1ae932d in GSEventRun 32: 0x30a42e in UIApplicationMain 33: 0x2914 in main at /Application/main.m:14 34: 0x28a5 in startAlloc: Block address: 0x04d90af0 length: 24Stack - pthread: 0xa0078540 number of frames: 40 0: 0x90e5a103 in malloc_zone_calloc 1: 0x90e5a05a in calloc 2: 0x13fdd0f in _internal_class_createInstanceFromZone 3: 0x140087d in class_createInstance 4: 0x123e687 in __CFAllocateObject2 5: 0x12a2d64 in +[__NSArrayI __new::] 6: 0x121faba in +[NSArray arrayWithObjects:count:] 7: 0x127ca9 in -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:] 8: 0x24b0d in -[Task getFullSession:intoArray:] at /Application/Task.m:177 9: 0x604d in -[AViewController viewDidLoad] at /Application/Classes/AViewController.m:50 10: 0x3a965e in -[UIViewController view] 11: 0x3a7a57 in -[UIViewController contentScrollView] 12: 0x3b8201 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] 13: 0x3b6831 in -[UINavigationController _layoutViewController:] 14: 0x3b7b4c in -[UINavigationController _startTransition:fromViewController:toViewController:] 15: 0x3b2606 in -[UINavigationController _startDeferredTransitionIfNeeded] 16: 0x4cae01 in -[UILayoutContainerView layoutSubviews] 17: 0x1e87451 in -[CALayer layoutSublayers] 18: 0x1e8717c in CALayerLayoutIfNeeded 19: 0x1e87088 in -[CALayer layoutIfNeeded] 20: 0x3aab5f in -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] 21: 0x3238e9 in -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] 22: 0x5a2948 in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] 23: 0x3ad982 in -[UIViewController presentModalViewController:withTransition:] 24: 0x3a6269 in -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] 25: 0x3ad085 in -[UIViewController presentModalViewController:withTransition:] 26: 0x4bc0 in -[RootViewController tableView:didSelectRowAtIndexPath:] at /Application/Classes/RootViewController.m:98 27: 0x371794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] 28: 0x367d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] 29: 0x7a7f6 in __NSFireDelayedPerform 30: 0x128afe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ 31: 0x128c594 in __CFRunLoopDoTimer 32: 0x11e8cc9 in __CFRunLoopRun 33: 0x11e8240 in CFRunLoopRunSpecific 34: 0x11e8161 in CFRunLoopRunInMode 35: 0x1ae9268 in GSEventRunModal 36: 0x1ae932d in GSEventRun 37: 0x30a42e in UIApplicationMain 38: 0x2914 in main at /Application/main.m:14 39: 0x28a5 in start
The cause of this error is visible near the top of theblock:
...4: 0x127c89 in -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:]5: 0x24b0d in -[Task getFullSession:intoArray:] at /Application/Task.m:177...2: 0x127c89 in -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:]3: 0x24b0d in -[Task getFullSession:intoArray:] at /Application/Task.m:177...7: 0x127ca9 in -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:]8: 0x24b0d in -[Task getFullSession:intoArray:] at /Application/Task.m:177
0 0
- XCode4设置NSZombieEnabled
- xCode4里面设置NSZombieEnabled
- xCode4里面设置NSZombieEnabled
- xCode4里面设置NSZombieEnabled
- xCode4里面设置NSZombieEnabled
- xCode4设置NSZombieEnabled
- 如何在XCode4中设置NSZombieEnabled & MallocStackLogging
- 由xCode4里面设置NSZombieEnabled,解决EXC_BAD_ACCESS问题引出
- Xcode4 下设置 NSZombieEnabled 的方法打出错误日志(转载)
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled捕捉错误
- 定位EXC_BAD_ACCESS错误 设置NSZombieEnabled
- 设置 NSZombieEnabled 定位 EXC_BAD_ACCESS 错误
- 设置 NSZombieEnabled 定位 EXC_BAD_ACCESS 错误
- 设置 NSZombieEnabled 定位 EXC_BAD_ACCESS 错误
- Hibernate重点知识笔记-必看
- 理解iphone开发中的delegate(委托)
- AVOS Cloud 技术支持系统开源了
- BW Query变量增强(时间及文本)
- IPhone数据库操作代码例子
- xCode4设置NSZombieEnabled
- 纠错感言-无语的缓存
- NSSET and NSArray
- Lucene简单示例详解
- 软件工程实训教程网址
- Messenger:使用消息的跨进程通信
- jar包中资源问题总结
- The resource is not on the build path of a java project解决方法
- UI设计书籍推荐