为什么iOS应用程序在收到UIApplicationDidReceiveMemoryWarningNotification时崩溃

时间:2017-09-28 03:51:02

标签: ios objective-c

最近,我收到了很多使用iOS 8.x的客户的崩溃日志。这里是日志,

Application received signal SIGSEGV
current state:Foreground,total time:0H0M34S,active time:0H0M29S
iOS Version:8.1.1 (12B435)
(null)
((
0 CoreFoundation 0x219b060f exceptionPreprocess (in CoreFoundation) + 151
1 libobjc.A.dylib 0x35b53c77 objc_exception_throw + 38
2 CoreFoundation 0x219b053d -[NSException initWithCoder:] (in CoreFoundation) + 1
3 my app 0x47f61b UmengSignalHandler (in my app) + 137
4 libsystem_platform.dylib 0x3622f09b _sigtramp + 34
5 CoreFoundation 0x21968f15 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation) + 13
6 CoreFoundation 0x281f4e4d _CFXNotificationPost + 1800
7 Foundation 0x225f8ec1 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation) + 77
8 Foundation 0x225fda3f -[NSNotificationCenter postNotificationName:object:] (in Foundation) + 31
9 UIKit 0x250bf913 -[UIApplication _performMemoryWarning] (in UIKit) + 139
10 libdispatch.dylib 0x2f78340f _dispatch_client_callout (in libdispatch.dylib) + 23
11 libdispatch.dylib 0x2f798709 _dispatch_source_latch_and_call (in libdispatch.dylib) + 621
12 libdispatch.dylib 0x2f791f3d _dispatch_source_invoke$VARIANT$mp (in libdispatch.dylib) + 213
13 libdispatch.dylib 0x2f78e035 _dispatch_main_queue_callback_4CF$VARIANT$mp (in libdispatch.dylib) + 329
14 CoreFoundation 0x21976631 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE (in CoreFoundation) + 9
15 CoreFoundation 0x21974d51 __CFRunLoopRun (in CoreFoundation) + 1513
16 CoreFoundation 0x281f2b31 CFRunLoopRunSpecific + 476
17 CoreFoundation 0x281f2943 CFRunLoopRunInMode + 106
18 GraphicsServices 0x2f5d2051 GSEventRunModal + 136
19 UIKit 0x2b7e86f1 UIApplicationMain + 1440
20 my app 0x28b8cd main (in eif-ios-app) (main.m:27)
21 libdyld.dylib 0x2f7beaaf start (in libdyld.dylib) + 3
)

从日志中,我们可以发现应用程序在收到内存不足警告时崩溃了。我的项目代码永远不会运行,所以我想僵尸对象发生了。 因为zombie与UIApplicationDidReceiveMemoryWarningNotification相关联,所以我搜索了每个观察通知的地方。 结果,所有观察者都以dealloc删除,除了属于单身人士的观察者。 现在我不知道如何解决这个崩溃。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

有多种方法可以调试此问题。

  1. 在调试时,您可以在XCode中检查调试导航器中的内存。如果您按下新屏幕,内存应该会增加,如果弹出屏幕,内存会减少。如果if没有减少,这可能是内存泄漏的情况,你需要解决它以防止崩溃。 enter image description here

  2. 在XCode中,有一种方法可以在调试时生成内存图。您可以使用它来查找发生内存泄漏的实例。

  3. enter image description here