仪器在main.m中显示泄漏(Xcode 4.3.1)

我正在开发一个应用程序使用ARC当我的应用程序分析仪器内存泄漏时,它显示在以下function的泄漏:

#import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } 

这是否表示在我的代码中的其他地方的问题?

这是堆栈跟踪

  0 libsystem_c.dylib malloc 1 libsystem_c.dylib strdup 2 libnotify_sim.dylib token_table_add 3 libnotify_sim.dylib notify_register_mach_port 4 libnotify_sim.dylib notify_register_dispatch 5 CoreFoundation _CFXNotificationRegisterObserver 6 CoreFoundation CFNotificationCenterAddObserver 7 UIKit -[UIScrollView(Static) _startTimer:] 8 UIKit -[UIScrollView _endPanWithEvent:] 9 UIKit -[UIScrollView handlePan:] 10 UIKit _UIGestureRecognizerSendActions 11 UIKit -[UIGestureRecognizer _updateGestureWithEvent:] 12 UIKit -[UIGestureRecognizer _delayedUpdateGesture] 13 UIKit ___UIGestureRecognizerUpdate_block_invoke_0541 14 UIKit _UIGestureRecognizerApplyBlocksToArray 15 UIKit _UIGestureRecognizerUpdate 16 UIKit -[UIWindow _sendGesturesForEvent:] 17 UIKit -[UIWindow sendEvent:] 18 UIKit -[UIApplication sendEvent:] 19 UIKit _UIApplicationHandleEvent 20 GraphicsServices PurpleEventCallback 21 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ 22 CoreFoundation __CFRunLoopDoSource1 23 CoreFoundation __CFRunLoopRun 24 CoreFoundation CFRunLoopRunSpecific 25 CoreFoundation CFRunLoopRunInMode 26 GraphicsServices GSEventRunModal 27 GraphicsServices GSEventRun 28 UIKit UIApplicationMain 29 MyProject/main.m:16 30 MyProject start 

这似乎是在iOS 5.1框架中的一个错误: https : //devforums.apple.com/message/630695

我在使用ARC时遇到了同样的问题,这是由视图控制器中的dealloc函数引起的。 通过使用dealloc函数(这在我的情况下没有做任何事情),可能不会调用默认行为。 尝试注释dealloc的所有实例,并应该解决您的问题。

你的main.m看起来不像我见过的其他人。 你是用这种方式格式化还是自动完成的? 这里是我的一个ARC应用程序的例子。

 int main(int argc, char *argv[]) { @autoreleasepool { int retVal = UIApplicationMain(argc, argv, nil, nil); return retVal; } }