swift memory issues since iOS 11 or iOS 10.3 -
i have app using geofencing , beacons since 1 year in app store. noticed more , more crashes , users reporting of missing notifications upon geofence entry or exit ( send local notification upon entry or exit). suspect crash reports related user reports. crash reports indicate memory management issues: lib dispatch.dylib _dispatch_callblock_and_release
these problem occur since ios 10.3. have reports ios 10.3 of them ios 11. when run app in simulator memory usage @ around 50mb , not increase. when simulate geofence entry , exit etc stays around 50 mb usage.
so first question possible app crashes when not in foreground when uses 50mb?
to investigate further implemented function func applicationdidreceivememorywarning(_ application: uiapplication) , send local notification when get´s called. , indeed sometimes warning , myself have irregularities geofence enter , exit notifications.
now further investigate installed app monitor same geofence (ifttt). here have irregularities geofence enter , exit notifications.
until quite relaxed sure it´s ios 11 beta´s have memory management issue. i´m using latest beta (15a5372a) , guess close final now. worries me users experience these issues ios 10.3.
any ideas how investigate further or experience similar?
very best stephan
edit: today again experience strange behaviour ios 11 golden master. yesterday afternoon @ around 16:30 arrived home. ifttt didenterregion not triggered. or @ least did not notification. when left home morning got exit notification @ same time enter yesterday. i´m suspecting general change in memory allocation ios 11 has when apps run in background.
edit:
i did further investiagation.. implemented method applicationdidreceivememorywarning , displayed waring beta testers.
here´s code:
func applicationdidreceivememorywarning(_ application: uiapplication) { let memoryinuse = report_memory() let notification = uilocalnotification() notification.alertbody = "memorywarning. memory in use: \(memoryinuse)" notification.soundname = "default" uiapplication.shared.presentlocalnotificationnow(notification) print("memorywarning. memory in use: \(memoryinuse)") }
to see how memory application using have function:
func report_memory() -> string { var taskinfo = mach_task_basic_info() var count = mach_msg_type_number_t(memorylayout<mach_task_basic_info>.size)/4 let kerr: kern_return_t = withunsafemutablepointer(to: &taskinfo) { $0.withmemoryrebound(to: integer_t.self, capacity: 1) { task_info(mach_task_self_, task_flavor_t(mach_task_basic_info), $0, &count) } } if kerr == kern_success { print("memory used in bytes: \(taskinfo.resident_size)") } else { print("error task_info(): " + (string(cstring: mach_error_string(kerr), encoding: string.encoding.ascii) ?? "unknown error")) return "error" } let mbinuse = taskinfo.resident_size / 1000000 return string(mbinuse) + " mb" }
i got first feedbacks users. memory waringing between 7 , 18mb reported function report_memory().
so i´m scratching head if either code wrong , memory in use not reported correctly or if it´s possible iphone 6 or 7 report memory warning when app using 7mb while being active in background (while entering geofence or beacon region).
many stephan
Comments
Post a Comment