ios – 在仪器中进行性能分析时出现SIGSEGV(内存不良访问)错误

ios – 在仪器中进行性能分析时出现SIGSEGV(内存不良访问)错误,第1张

概述我正试图通过仪器工具中的Leak Profiler来捕获内存泄漏并保留周期.但是,每当我单击Instruments中的记录按钮时,应用程序看起来就像启动然后崩溃一样.如果我从 Xcode打开应用程序并将其转移到Instruments,则在我点击任何UIButton后应用程序崩溃.如果我从模拟器打开应用程序,我可以获得第二个屏幕,但随后它也会崩溃.此外,App不会在内存图中显示任何泄漏,也不会在正常 我正试图通过仪器工具中的Leak Profiler来捕获内存泄漏并保留周期.但是,每当我单击Instruments中的记录按钮时,应用程序看起来就像启动然后崩溃一样.如果我从 Xcode打开应用程序并将其转移到Instruments,则在我点击任何UIbutton后应用程序崩溃.如果我从模拟器打开应用程序,我可以获得第二个屏幕,但随后它也会崩溃.此外,App不会在内存图中显示任何泄漏,也不会在正常使用时崩溃.

这是崩溃日志;

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000018 VM Region Info: 0x18 is not
in any region. Bytes before following region: 4377985000
REGION TYPE START – END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
—>
__TEXT 0000000104f2c000-0000000104fbc000 [ 576K] r-x/r-x SM=COW …ti App Test]

@H_502_22@

  
  终止信号:分段故障:11终止原因:
  命名空间SIGNAL,代码0xb终止进程:exc处理程序[0]
  由线程触发:0
  
  已过滤的系统日志:未找到
  
  线程0名称:dispatch队列:com.apple.main-thread线程0
  崩溃:0 libswiftCore.dylib 0x000000010597b2b4
  0x1058cc000 717492 1 libswiftCore.dylib
    0x000000010598823c 0x1058cc000 770620 2 UIFoundation
    0x000000018f01fbdc attributeDictionaryHash 460 3基础
    0x0000000185417edc hashProbe 72 4基础
    0x0000000185417e7c – [NSConcreteHashtable getItem:] 40 5
  UIFoundation 0x000000018f01fd54
   [NSAttributeDictionary newWithDictionary:] 136 6基础0x000000018542666c – [NSConcreteAttributedString
  initWithString:attributes:] 124 7我的App测试
    0x0000000104fbb894 0x104f2c000 587924 8我的App测试
    0x0000000104fba588 0x104f2c000 583048 9我的App测试
    0x0000000104fba494 0x104f2c000 582804 10我的App测试
    0x0000000104fb9964 0x104f2c000 579940 11我的App测试
    0x0000000104fb9830 0x104f2c000 579632 12我的App测试
    0x0000000104fcb608 0x104f2c000 652808 13我的App测试
    0x0000000104fccea4 0x104f2c000 659108 14我的App测试
    0x0000000104fcc50c 0x104f2c000 656652 15我的App测试
    0x0000000104fcc5a0 0x104f2c000 656800 16 UIKit
    0x000000018df36bfc – [UIVIEwController loadVIEwIfrequired] 1040 17
  UIKit 0x000000018df367d4 – [UIVIEwController
  查看] 28 18我的应用程序测试0x0000000104f85b6c 0x104f2c000
    367468 19我的应用测试0x0000000104f85470 0x104f2c000 365680 20我的应用测试0x0000000104f85688 0x104f2c000
  366216 21 UIKit 0x000000018df6b20c
   – [UIApplication sendAction:to:from:forEvent:] 96 22 UIKit 0x000000018df6b18c – [UIControl sendAction:to:forEvent:] 80 23
  UIKit 0x000000018df55f4c – [UIControl
  _sendActionsForEvents:withEvent:] 440 24 UIKit 0x000000018df6aa80 – [UIControl touchesEnded:withEvent:] 576 25
  UIKit 0x000000018df6a5a0 – [UIWindow
  _sendtouchesForEvent:] 2544 26 UIKit 0x000000018df65a70 – [UIWindow sendEvent:] 3208 27 UIKit
    0x000000018df37078 – [UIApplication sendEvent:] 340 28 UIKit
    0x000000018e876f98 dispatchPreprocessedEventFromEventQueue 2364
  29 UIKit 0x000000018e879408
  __handleEventQueueInternal 4760 30 UIKit 0x000000018e872574 __handleHIDEventFetcherDrain 152 31
  CoreFoundation 0x0000000184ad0358
  __CFRUNLOOP_IS_CALliNG_OUT_TO_A_SOURCE0_PERFORM_FUNCTION 24 32 CoreFoundation 0x0000000184ad02d8 __CFRunLoopDoSource0
    88 33 CoreFoundation 0x0000000184acfb60 __CFRunLoopDoSources0 204 34 CoreFoundation 0x0000000184acd738 __CFRunLoopRun 1048 35 CoreFoundation
    0x00000001849ee2d8 CFRunLoopRunspecific 436 36 GraphiCSServices
    0x000000018687ff84 GSEventRunModal 100 37 UIKit
    0x000000018df9a880 UIApplicationMain 208 38我的App测试
    0x0000000104f97854 0x104f2c000 440404 39 libdyld.dylib
    0x000000018451256c开始4
  
  线程1:0 libsystem_kernel.dylib 0x0000000184641dbc
  __workq_kernreturn 8 1 libsystem_pthread.dylib 0x0000000184753144 _pthread_wqthread 1288 2
  libsystem_pthread.dylib 0x0000000184752c30 start_wqthread 4
  
  线程2:0 libsystem_pthread.dylib 0x0000000184752c2c
  start_wqthread 0
  
  线程3名称:com.apple.uikit.eventfetch-thread线程3:0
  libsystem_kernel.dylib 0x0000000184620bc4 mach_msg_trap 8 1
  libsystem_kernel.dylib 0x0000000184620a3c mach_msg 72 2
  CoreFoundation 0x0000000184acfce4
  CFRunLoopServiceMachPort 196 3 CoreFoundation 0x0000000184acd8b0 __CFRunLoopRun 1424 4 CoreFoundation
    0x00000001849ee2d8 CFRunLoopRunspecific 436 5基础
    0x00000001854166e4 – [NSRunLoop 50916(NSRunLoop)
  runMode:beforeDate:] 304 6基础
    0x0000000185435afc – [NSRunLoop 178940(NSRunLoop)runUntilDate:]
  96 7 UIKit 0x000000018eae602c
   – [UIEventFetcher threadMain] 136 8基础0x0000000185517860 __NSThread__start 996 9
  libsystem_pthread.dylib 0x000000018475432c _pthread_body 308
  10 libsystem_pthread.dylib 0x00000001847541f8 _pthread_body
  0 11 libsystem_pthread.dylib 0x0000000184752c38 thread_start
  4
  
  线程4:0 libsystem_pthread.dylib 0x0000000184752c2c
  start_wqthread 0
  
  线程5名称:com.apple.NSURLConnectionLoader线程5:0
  libsystem_kernel.dylib 0x0000000184620bc4 mach_msg_trap 8 1
  libsystem_kernel.dylib 0x0000000184620a3c mach_msg 72 2
  CoreFoundation 0x0000000184acfce4
  CFRunLoopServiceMachPort 196 3 CoreFoundation 0x0000000184acd8b0 __CFRunLoopRun 1424 4 CoreFoundation
    0x00000001849ee2d8 CFRunLoopRunspecific 436 5 CFNetwork
    0x0000000185157b40 [NSURLConnection 715584(装载机)
  _resourceLoadLoop:] 404 6基金会0x0000000185517860 __NSThread__start 996 7
  libsystem_pthread.dylib 0x000000018475432c _pthread_body 308
  8 libsystem_pthread.dylib 0x00000001847541f8 _pthread_body
  0 9 libsystem_pthread.dylib 0x0000000184752c38 thread_start
  4
  
  线程0与ARM线程状态(64位)崩溃:
      x0:0x00000001c4227ac0 x1:0x000000018eca2db2 x2:0x000000016aecf908 x3:0x0000000000000000
      x4:0x0000000000000000 x5:0x0000000000000020 x6:0x0000000185426654 x7:0x0000000000000130
      x8:0x0000000000000000 x9:0x0000000000000000 x10:0x0119490101194980 x11:0x0000000001194901 x12:0x0000000001194800
  x13:0x0000000000000001 x14:0x0000000000000000 x15:
  0x01194901011949c0 x16:0x0000000000000000 x17:0x0000000105988228
  x18:0x0000000000000000 x19:0x00000001c4227ac0 x20:
  0x00000001c4227ac0 x21:0x00000001b5421000 x22:0x00000001c0124f60
  x23:0x0000000000000000 x24:0x00000001c0200730 x25:
  0x0000000000000000 x26:0x000000018eca3f46 x27:0x00000001b3bca000
  x28:0x00000001c04578e0 fp:0x000000016aecf4f0 lr:
  0x000000010598823c
      sp:0x000000016aecf4e0 pc:0x000000010597b2b4 cpsr:0x20000000

我正在搜索这个月一个月,我不确定它是否是一个仪器BUG.我查了下面的帖子;

Xcode Instruments: Leaks – App crashes on launch

Instruments crashing while using Leaks instrument

xcode instruments causing app crash

编辑:另一个崩溃日志.在这个我打开应用程序并将内存传输到仪器工具并触摸UIVIEw顶部打开一个新的控制器.

Date/Time: 2018-07-06 15:13:34.5980 +0300 Launch Time: 2018-07-06 15:13:19.6298 +0300 OS Version: iPhone OS 11.0
(15A372) Baseband Version: 2.00.01 Report Version: 104

@H_502_22@

  
  异常类型:EXC_BAD_ACCESS(SIGSEGV)异常子类型:
  KERN_INVALID_ADDRESS位于0x0000000000000018 VM区域信息:0x18不是
  在任何地区.以下地区之前的字节数:4330094568
        区域类型开始 – 结束[VSIZE] PRT / MAX SHRMOD区域详细信息
        开始时未使用的空间
  —>
        __TEXT 0000000102180000-00000001022a0000 [1152K] r-x / r-x SM = COW … ti Filo Test]
  
  终止信号:分段故障:11终止原因:
  命名空间SIGNAL,代码0xb终止进程:exc处理程序[0]
  由线程触发:0
  
  已过滤的系统日志:未找到
  
  线程0名称:dispatch队列:com.apple.main-thread线程0
  崩溃:0 libswiftCore.dylib 0x0000000102bdf278
  0x102b30000 717432 1 libswiftCore.dylib
    0x0000000102bec1b0 0x102b30000 770480 2 CoreFoundation
    0x0000000184a3ec80 – [NSDictionary allKeys] 108 3 UIKit
    0x000000018e15738c – [NSDictionary 2294668
  (UIStringDrawingKeyCompatibility)
  _ui_attributesForDictionaryContainingUIStringDrawingKeys] 36 4 UIKit 0x000000018e09fde0 – [UINavigationbar
  setTitleTextAttributes:] 144 5我的App测试
    0x00000001021e82e8 0x102180000 426728 6我的App测试
    0x00000001021e67c8 0x102180000 419784 7我的App测试
    0x00000001021e6a14 0x102180000 420372 8 UIKit
    0x000000018e5c3f78 – [UIGestureRecognizerTarget
  _sendActionWithGestureRecognizer:] 64 9 UIKit 0x000000018e5c84dc _UIGestureRecognizerSendTargetActions 124 10
  UIKit 0x000000018e0b2dc8
  _UIGestureRecognizerSendActions 320 11 UIKit 0x000000018df67748 – [UIGestureRecognizer
  _updateGestureWithEvent:buttonEvent:] 732 12 UIKit 0x000000018e5b23fc _UIGestureEnvironmentUpdate 1056 13 UIKit
    0x000000018e5b1f88 – [UIGestureEnvironment
  _deliverEvent:toGestureRecognizers:usingBlock:] 404 14 UIKit 0x000000018e5b10e4 – [UIGestureEnvironment
  _updateGesturesForEvent:window:] 276 15 UIKit 0x000000018df65a54 – [UIWindow sendEvent:] 3180 16 UIKit
    0x000000018df37078 – [UIApplication sendEvent:] 340 17 UIKit
    0x000000018e876f98 dispatchPreprocessedEventFromEventQueue 2364
  18 UIKit 0x000000018e879408
  __handleEventQueueInternal 4760 19 UIKit 0x000000018e872574 __handleHIDEventFetcherDrain 152 20
  CoreFoundation 0x0000000184ad0358
  __CFRUNLOOP_IS_CALliNG_OUT_TO_A_SOURCE0_PERFORM_FUNCTION 24 21 CoreFoundation 0x0000000184ad02d8 __CFRunLoopDoSource0
    88 22 CoreFoundation 0x0000000184acfb60 __CFRunLoopDoSources0 204 23 CoreFoundation 0x0000000184acd738 __CFRunLoopRun 1048 24 CoreFoundation
    0x00000001849ee2d8 CFRunLoopRunspecific 436 25 GraphiCSServices
    0x000000018687ff84 GSEventRunModal 100 26 UIKit
    0x000000018df9a880 UIApplicationMain 208 27我的App测试
    0x00000001021facdc 0x102180000 503004 28 libdyld.dylib
    0x000000018451256c开始4
  
  线程1:0 libsystem_pthread.dylib 0x0000000184752c2c
  start_wqthread 0
  
  线程2:0 libsystem_pthread.dylib 0x0000000184752c2c
  start_wqthread 0
  
  线程3:0 libsystem_pthread.dylib 0x0000000184752c2c
  start_wqthread 0
  
  线程4名称:com.apple.uikit.eventfetch-thread线程4:0
  libsystem_kernel.dylib 0x0000000184620bc4 mach_msg_trap 8 1
  libsystem_kernel.dylib 0x0000000184620a3c mach_msg 72 2
  CoreFoundation 0x0000000184acfce4
  CFRunLoopServiceMachPort 196 3 CoreFoundation 0x0000000184acd8b0 __CFRunLoopRun 1424 4 CoreFoundation
    0x00000001849ee2d8 CFRunLoopRunspecific 436 5基础
    0x00000001854166e4 – [NSRunLoop 50916(NSRunLoop)
  runMode:beforeDate:] 304 6基础
    0x0000000185435afc – [NSRunLoop 178940(NSRunLoop)runUntilDate:]
  96 7 UIKit 0x000000018eae602c
   – [UIEventFetcher threadMain] 136 8基础0x0000000185517860 __NSThread__start 996 9
  libsystem_pthread.dylib 0x000000018475432c _pthread_body 308
  10 libsystem_pthread.dylib 0x00000001847541f8 _pthread_body
  0 11 libsystem_pthread.dylib 0x0000000184752c38 thread_start
  4
  
  线程5名称:GAIThread线程5:0 libsystem_kernel.dylib
    0x0000000184620bc4 mach_msg_trap 8 1 libsystem_kernel.dylib
    0x0000000184620a3c mach_msg 72 2 CoreFoundation
    0x0000000184acfce4 CFRunLoopServiceMachPort 196 3
  CoreFoundation 0x0000000184acd8b0 __CFRunLoopRun
  1424 4 CoreFoundation 0x00000001849ee2d8
  CFRunLoopRunspecific 436 5基金会
    0x00000001854166e4 – [NSRunLoop 50916(NSRunLoop)
  runMode:beforeDate:] 304 6基础
    0x000000018546862c – [NSRunLoop 386604(NSRunLoop)运行] 88 7我的
  应用测试0x000000010225b108 0x102180000 897288 8
  基金会0x0000000185517860 __NSThread__start
    996 9 libsystem_pthread.dylib 0x000000018475432c _pthread_body 308 10 libsystem_pthread.dylib 0x00000001847541f8 _pthread_body 0 11 libsystem_pthread.dylib
    0x0000000184752c38 thread_start 4
  
  线程6名称:com.apple.NSURLConnectionLoader线程6:0
  libsystem_kernel.dylib 0x0000000184620bc4 mach_msg_trap 8 1
  libsystem_kernel.dylib 0x0000000184620a3c mach_msg 72 2
  CoreFoundation 0x0000000184acfce4
  CFRunLoopServiceMachPort 196 3 CoreFoundation 0x0000000184acd8b0 __CFRunLoopRun 1424 4 CoreFoundation
    0x00000001849ee2d8 CFRunLoopRunspecific 436 5 CFNetwork
    0x0000000185157b40 [NSURLConnection 715584(装载机)
  _resourceLoadLoop:] 404 6基金会0x0000000185517860 __NSThread__start 996 7
  libsystem_pthread.dylib 0x000000018475432c _pthread_body 308
  8 libsystem_pthread.dylib 0x00000001847541f8 _pthread_body
  0 9 libsystem_pthread.dylib 0x0000000184752c38 thread_start
  4
  
  线程0与ARM线程状态(64位)崩溃:
      x0:0x00000001c4227c60 x1:0x000000018eca2db2 x2:0x0000000000000000 x3:0x000000010637e8d0
      x4:0x0000000000000002 x5:0x0000000000000020 x6:0x00000001021e82e8 x7:0x0000000000000b70
      x8:0x0000000000000000 x9:0x0000000000000000 x10:0x01446b0101446b80 x11:0x0000000001446b01 x12:0x0000000001446a00
  x13:0x0000000000000001 x14:0x0000000000000000 x15:
  0x01446b0101446bc0 x16:0x0000000000000000 x17:0x0000000102bec19c
  x18:0x0000000000000000 x19:0x00000001c4227c60 x20:
  0x00000001c4227c60 x21:0x00000001c4227c60 x22:0x00000000000000d0
  x23:0x00000000000001f0 x24:0x0000000000000008 x25:
  0x00000001c4107740 x26:0x00000001c40ca6b0 x27:0x00000001c4093330
  x28:0x00000001b3f8f000 fp:0x000000016dc7ce40 lr:
  0x0000000102bec1b0
      sp:0x000000016dc7ce30 pc:0x0000000102bdf278 cpsr:0x20000000

编辑:@FranticRock s’回答后.当我删除[UINavigationbar setTitleTextAttributes:]时,详细信息类可以打开,但不显示任何项目(标题,后退按钮或任何单元格).它们都是空的,我还在泄漏.

这是控制器类,我在哪里写[UINavigationbar setTitleTextAttributes:]

class WelcomeVIEwController: BaseVIEwController {let bgVIEw = UIVIEw()let backgroundImage = UIImageVIEw()let logoImage: UIImageVIEw = {    let i = UIImageVIEw()    i.image = UIImage(named: "full_logo")    i.contentMode = .scaleAspectFit    return i}()let welcomeLabel : UILabel = {    let l = UILabel()    l.Font = Fonts.Font.withSize(24)    l.textcolor = UIcolor.white    l.textAlignment = .center    l.numberOflines = 0    l.sizetoFit()    return l}()let loginLbl: UILabel = {    let l = UILabel()    l.Font = Fonts.Font.withSize(13)    l.textcolor = UIcolor.white    l.textAlignment = .center    l.numberOflines = 0    l.sizetoFit()    return l}()let adminBtn: UIbutton = {    let b = UIbutton()    b.backgroundcolor = color.Common.buttoncolor    b.layer.cornerRadius = 6.0    return b}()let userBtn: UIbutton = {    let b = UIbutton()    b.backgroundcolor = color.Common.buttoncolor    b.layer.cornerRadius = 6.0    return b}()lazy var supportedServicesVIEw = WelcomeScreenbuttonVIEw(text: getLabelText(key: CMSKeys.CMS_LBL_SUPPORTEDSERVICES),imagename: "phone")lazy var incIDentVIEw = WelcomeScreenbuttonVIEw(text: getLabelText(key: CMSKeys.CMS_LBL_INCIDENT),imagename: "phone")lazy var contactUsVIEw = WelcomeScreenbuttonVIEw(text: getLabelText(key:CMSKeys.CMS_LBL_CONTACT),imagename: "phone")lazy var moreVIEw = WelcomeScreenbuttonVIEw(text: getLabelText(key:CMSKeys.CMS_LBL_MORE),imagename: "wdiger")lazy var emergencyBtn = Sendbutton(text: "button")let firstStackVIEw = UIStackVIEw()let secondStackVIEw = UIStackVIEw()let thirdStackVIEw = UIStackVIEw()let btnStackVIEw = UIStackVIEw()overrIDe func vIEwDIDLoad() {    super.vIEwDIDLoad()    self.setPageID()    designUI()}overrIDe func vIEwDIDAppear(_ animated: Bool) {    if(AppContext.instance.comesFromURL != nil){        comesFromURL()    }}overrIDe func vIEwWillAppear(_ animated: Bool) {    if(analyticsname != nil){        self.sendDataToGA()    }}overrIDe func vIEwDIDLayoutSubvIEws() {    bgVIEw.anchor(self.thirdStackVIEw.topAnchor,left: self.vIEw.leftAnchor,bottom: self.vIEw.bottomAnchor,right: self.vIEw.rightAnchor,topConstant: 40,leftConstant: 0,bottomConstant: 0,rightConstant: 0,wIDthConstant: 0,heightConstant: 0)    let margins = vIEw.layoutmarginsGuIDe    thirdStackVIEw.leadingAnchor.constraint(equalTo: margins.leadingAnchor,constant: 5).isActive = true    thirdStackVIEw.trailingAnchor.constraint(equalTo: margins.trailingAnchor,constant: -5).isActive = true    thirdStackVIEw.bottomAnchor.constraint(equalTo: self.emergencyBtn.topAnchor,constant: -10).isActive = true    thirdStackVIEw.heightAnchor.constraint(equalTo: thirdStackVIEw.wIDthAnchor,multiplIEr: 0.77).isActive = true    emergencyBtn.anchor(nil,bottom: self.bottomLayoutGuIDe.topAnchor,topConstant: 10,leftConstant: 20,bottomConstant: 20,rightConstant: 20,heightConstant: 48)    if #available(iOS 11.0,*) {        logoImage.anchor(self.vIEw.safeAreaLayoutGuIDe.topAnchor,bottom: nil,leftConstant: 80,rightConstant: 80,heightConstant: 0)    } else {        logoImage.anchor(self.vIEw.topAnchor,heightConstant: 0)        // Fallback on earlIEr versions    }    logoImage.anchorCenterXToSupervIEw()    let welcomeLblHeight = heightForVIEw(text: "Welcome",Font: welcomeLabel.Font,wIDth: self.vIEw.bounds.wIDth)    let loginLblHeight = heightForVIEw(text: "Please Log In",Font: loginLbl.Font,wIDth: self.vIEw.bounds.wIDth)    welcomeLabel.anchor(self.logoImage.bottomAnchor,topConstant: 0,leftConstant: 50,rightConstant: 50,heightConstant: welcomeLblHeight)    loginLbl.anchor(self.welcomeLabel.bottomAnchor,heightConstant: loginLblHeight)    btnStackVIEw.anchor(nil,bottom: self.thirdStackVIEw.topAnchor,heightConstant: 50)    backgroundImage.frame = CGRect(x: 0,y: 0,wIDth: self.vIEw.frame.wIDth,height: self.vIEw.frame.height - self.bgVIEw.frame.height)}private func designUI(){    self.vIEw.translatesautoresizingMaskIntoConstraints = true    backgroundImage.image = UIImage(named: "background.png")    backgroundImage.contentMode = .scaleAspectFill    self.vIEw.insertSubvIEw(backgroundImage,at: 0)    bgVIEw.backgroundcolor = color.Common.welcomeScreenBackgroundcolor    self.vIEw.insertSubvIEw(bgVIEw,at: 1)    vIEw.addSubvIEw(logoImage)    welcomeLabel.text = getLabelText(key: CMSKeys.CMS_LBL_WELCOME)    vIEw.addSubvIEw(welcomeLabel)    loginLbl.text = getLabelText(key: CMSKeys.CMS_LBL_LOGIN)    vIEw.addSubvIEw(loginLbl)    adminBtn.backgroundcolor = color.Common.adminGreen    adminBtn.setTitle(getLabelText(key: CMSKeys.CMS_BTN_admin),for: .normal)    adminBtn.addTarget(self,action: #selector(adminBtnTapped(_:)),for: .touchUpInsIDe)    userBtn.backgroundcolor = color.Common.userGreen    userBtn.setTitle(getLabelText(key: CMSKeys.CMS_BTN_USER),for: .normal)    userBtn.addTarget(self,action: #selector(userBtnTapped(_:)),for: .touchUpInsIDe)    btnStackVIEw.axis  = UILayoutConstraintAxis.horizontal    btnStackVIEw.distribution = UIStackVIEwdistribution.fillEqually    btnStackVIEw.alignment = UIStackVIEwAlignment.fill    btnStackVIEw.spacing = 10.0    btnStackVIEw.addArrangedSubvIEw(adminBtn)    btnStackVIEw.addArrangedSubvIEw(userBtn)    btnStackVIEw.translatesautoresizingMaskIntoConstraints = false    self.vIEw.addSubvIEw(btnStackVIEw)    firstStackVIEw.axis  = UILayoutConstraintAxis.vertical    firstStackVIEw.distribution = UIStackVIEwdistribution.fillEqually    firstStackVIEw.alignment = UIStackVIEwAlignment.fill    firstStackVIEw.spacing = 10.0    firstStackVIEw.addArrangedSubvIEw(supportedServicesVIEw)    firstStackVIEw.addArrangedSubvIEw(contactUsVIEw)    firstStackVIEw.translatesautoresizingMaskIntoConstraints = false    secondStackVIEw.axis  = UILayoutConstraintAxis.vertical    secondStackVIEw.distribution = UIStackVIEwdistribution.fillEqually    secondStackVIEw.alignment = UIStackVIEwAlignment.fill    secondStackVIEw.spacing = 10.0    secondStackVIEw.addArrangedSubvIEw(incIDentVIEw)    secondStackVIEw.addArrangedSubvIEw(moreVIEw)    secondStackVIEw.translatesautoresizingMaskIntoConstraints = false    thirdStackVIEw.axis = UILayoutConstraintAxis.horizontal    thirdStackVIEw.distribution = UIStackVIEwdistribution.fillEqually    thirdStackVIEw.alignment = UIStackVIEwAlignment.fill    thirdStackVIEw.spacing = 10.0    thirdStackVIEw.addArrangedSubvIEw(firstStackVIEw)    thirdStackVIEw.addArrangedSubvIEw(secondStackVIEw)    thirdStackVIEw.translatesautoresizingMaskIntoConstraints = false    vIEw.addSubvIEw(thirdStackVIEw)    //VIEw Tap Gestures    let tapSupportedServices = UITapGestureRecognizer(target: self,action: #selector(self.tapSupportedServices(_:)))    supportedServicesVIEw.addGestureRecognizer(tapSupportedServices)    supportedServicesVIEw.isUserInteractionEnabled = true    let tAPIncIDentVIEw = UITapGestureRecognizer(target: self,action: #selector(self.tAPIncIDent(_:)))    incIDentVIEw.addGestureRecognizer(tAPIncIDentVIEw)    incIDentVIEw.isUserInteractionEnabled = true    let tapContactUs = UITapGestureRecognizer(target: self,action: #selector(self.tapContactUs(_:)))    contactUsVIEw.addGestureRecognizer(tapContactUs)    contactUsVIEw.isUserInteractionEnabled = true    let tapMoreVIEw = UITapGestureRecognizer(target: self,action: #selector(self.tapMore(_:)))    moreVIEw.addGestureRecognizer(tapMoreVIEw)    moreVIEw.isUserInteractionEnabled = true    emergencyBtn.layer.cornerRadius = 6.0    emergencyBtn.addTarget(self,action: #selector(emergenyBtnTapped(_:)),for: .touchUpInsIDe)    self.vIEw.addSubvIEw(emergencyBtn)}@objc func tapSupportedServices(_ sender: UITapGestureRecognizer) {    let linkingVC = SupportedServicesFirstVIEwController()    let controller = createNavController(Title: "Services",vIEwController: linkingVC)    self.present(controller,animated: true)}overrIDe func dIDReceiveMemoryWarning() {    super.dIDReceiveMemoryWarning()    // dispose of any resources that can be recreated.}private func heightForVIEw(text:String,Font:UIFont,wIDth:CGfloat) -> CGfloat{    let label:UILabel = UILabel(frame: CGRect(x: 0,wIDth: wIDth,height: CGfloat.greatestFiniteMagnitude))    label.numberOflines = 0    label.lineBreakMode = NSlineBreakMode.byWorDWrapPing    label.Font = Font    label.text = text    label.sizetoFit()    return label.frame.height}//Gets a Title and a VIEwController then returns a UINavigationController with attributesprivate func createNavController(Title: String,vIEwController: UIVIEwController) -> UINavigationController {    vIEwController.vIEw.backgroundcolor = UIcolor(red:0.87,green:0.87,blue:0.87,Alpha:1.0)    let navController = UINavigationController(rootVIEwController: vIEwController)    navController.navigationbar.topItem?.Title = Title    navController.navigationbar.barTintcolor = color.Navigationbar.tintcolor    navController.navigationbar.tintcolor = UIcolor.white    //Fix: Leak    navController.navigationbar.TitleTextAttributes = [NSAttributedStringKey.foregroundcolor: color.Navigationbar.textcolor]    return navController}private func removeVIEws(){    self.emergencyBtn.removeFromSupervIEw()    self.incIDentVIEw.removeFromSupervIEw()    self.moreVIEw.removeFromSupervIEw()    self.supportedServicesVIEw.removeFromSupervIEw()    self.contactUsVIEw.removeFromSupervIEw()}deinit {    print("Welcome Deinited")    removeVIEws()}}
@H_502_22@ @H_502_22@解决方法 在第一个堆栈跟踪中,有以下代码:[UINavigationbar setTitleTextAttributes:]
它试图通过在标题上设置文本属性来自定义导航栏.你在做吗?你可以尝试评论一下,看看问题是否消失了?

从技术上讲,你所拥有的不是内存泄漏.您正在访问已释放的对象.您可以做的另一件事是在您运行的方案上启用ZombIE Objects,并查看是否可以获取有关哪个对象已取消分配的信息.

现在,如果上面没有任何堆栈跟踪引导您直接编写任何代码,并且您说您已经使用了内存调试图工具并且没有找到任何对正在检查泄漏的对象的强引用,我会使用这里有一个更有创意的方法来找到问题.我经常使用的方法是消除.开始注释控制器的大部分,直到你只剩下空壳.每次,您都可以将代码缩减一半(日志性能),并重新测试代码的哪一部分引用已解除分配的对象.

显然,由于正常的应用程序 *** 作不会导致错误访问异常,它可能与XCode / Instruments内部相关,但上面的setTitleTextAttributes看起来很可疑,我首先会尝试缩小问题是否与导航栏相关.您是否对导航层次结构或导航栏UI的自定义做了一些奇怪的事情?

还要检查以前导航事件/实例在内存中是否存在同一个视图控制器的其他实例…这听起来像是一个UI对象被取消分配,然后由异步进程更新.

同样覆盖你的deinit {}.方法并在其中放置一个print语句,以检测所有被释放的相关对象.这将有助于缩小范围,以后将取消分配和访问哪个控制器.

它是出现在所有iOS版本/设备型号上还是仅出现在特定型号上?

总结

以上是内存溢出为你收集整理的ios – 在仪器中进行性能分析时出现SIGSEGV(内存不良访问)错误全部内容,希望文章能够帮你解决ios – 在仪器中进行性能分析时出现SIGSEGV(内存不良访问)错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1067877.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存