memory issues since iOS 11 or iOS 10.3

Hi,

I have an App that is using geofencing and beacons since about one year in the app store. Recently I noticed more and more crashes and users are reporting of missing notifications upon geofence entry or exit ( I send a local notification upon entry or exit).

so i suspect those crash reports are related to those user reports. The crash reports indicate memory management issues: lib dispatch.dylib _dispatch_callblock_and_release



These problem only occur since iOS 10.3. So I have some reports with iOS 10.3 but most of them with iOS 11. When I run the app in the simulator the memory usage is at around 50MB and does not increase. Even when I simulate geofence entry and exit etc it stays around the 50 MB usage.



So my first question is it possible that the app crashes when not in foreground when it uses only 50MB?



To investigate further I implemented the function func applicationDidReceiveMemoryWarning(_ application: UIApplication)

And send a local notification when it get´s called. And indeed sometimes I sometimes get this warning and I myself have irregularities with the geofence enter and exit notifications.



Now to further investigate I installed another App to monitor the same geofence (IFTTT). Here too I have irregularities with the geofence enter and exit notifications.



Until now I was quite relaxed as I was sure it´s the early iOS 11 beta´s that have memory management issue. But i´m using the latest Beta (15A5372a) and I guess we are close to the final now. Also what worries me is that some users experience these issues also with iOS 10.3.



Any ideas how to investigate this further or does anybody experience something similar?



Very Best

Stephan

Replies

https://i.stack.imgur.com/3eErW.jpg


Edit: Today I again experience a strange behaviour with the iOS 11 Golden Master. Yesterday Afternoon at around 16:30 I arrived home. The IFTTT didenterregion was not triggered. Or at least I did not get the notification. When I left home this morning I got the exit notification but at the same time the enter from yesterday. So I´m suspecting some general change in the memory allocation iOS 11 has when apps run in the background.

I did some further investiagation.. So I implemented the method applicationDidReceiveMemoryWarning and displayed this waring to my beta testers.


Here´s my 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 much memory the application is using I have this 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 with 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 the first feedbacks from users. The get this memory waringing frequently with something between 7 and 18MB reported from function report_memory().


So i´m scratching my head if either my code is wrong and the memory in use is not reported correctly or if really it´s possible for an iPhone 6 or 7 to report a memory warning when the app is using 7MB while being active in the background (while entering a geofence or a beacon region).


Many Thanks

Stephan

Yeah there is definitely something up with iOS 11 and memory management. I haven’t dug into the code yet of any of my iPad apps but have noticed bluetooth dropping to background apps (Merc bluetooth device), missed phone calls (hard to believe but true), ring fencing gps apps just not alerting me and even WhatsApp not displaying notifications on received messages. The background Bluetooth activity is nuts, I can replicate this by opening and using my phone with different apps and the Bluetooth drops everytime after about 5-6 apps used. Worked flawlessly in iOS 10.x Not to rant, but iOS 11 is extremely buggy on an iPhone 6. I was part of the beta and noticed reported bugs were just ignored or follow ups from “Apple” employees were poor and they never understood the issue.

I got this issue in 17.0 or above version. if any one can help me thanks in advance.

I got this issue in 17.0 or above version. if any one can help me thanks in advance.