Results 1 to 10 of 23

Thread: [iOS 3.0.3] While navigating, memory keeps growing until iOS kills my app.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Erfahrener skobbler
    Join Date

    [iOS 3.0.3] While navigating, memory keeps growing until iOS kills my app.

    Since I implemented SKMaps 3 in my app, users have been complaining about crashes while navigating / free driving. After analyses turns out my app is being killed by iOS due to excessive memory usage. (In case it matters: while on 2.5.1 I was using light maps, which are no longer available in 3.) Before you ask... I am quite positive my own code does not contain any memory leaks. This has been thoroughly analysed and fixed in earlier stages of development and also I didn't really change anything else when updating to 3 and there were no complaints when my app was still using 2.5.1 with light maps.

    While navigating, memory keeps on growing until a low memory warning is received. After analyses with Xcode's Instruments I see that memory is being freed when this warning is received, however apparently not always enough. I'm not sure, but it looks to me that some abandoned or leaked memory stays behind. Mostly in the form of non-object. I've been able to reproduce this in the (Swift) Demo App.

    Steps to reproduce in the demo app on simulator:
    1. In NavigationUIViewController
    - Comment out lines 31, 32, 33, 68, 69
    - between lines 69 and 70 add new lines:
mapView.settings.followUserPosition = true

    mapView.settings.displayMode = .mode3D

    mapView.settings.headingMode = .route

    mapView.animate(toZoomLevel: 8)
    - change line 43
from: navigationManager.startNavigation(with: configuration)

    to: navigationManager.startFreeDrive(with: configuration)

    2. Run the project in the iOS simulator (I used iPhone5SE)
    3. In the simulator 'Debug' menu select -> Location -> Apple
    4. Stop running the app
    5. Open Instruments
    6. Select the Allocations Tool
    7. Run the demo project from there (again on the iPhoneSE simulator for me)
    8. In the app select the Navigation UI (free drive will start)
    9. In the instruments tool do "Mark Generation' (I'm seeing an an initial growth of about 200MB) (on an actual device, iPhone6, this is only 95MB for the demo app and 110MB for my app)
    10. Now go to the simulator menu Debug -> Location -> Freeway drive (the map will start moving)
    11. In Instruments do a 'mark generation' every minute or so. You'll see the growth will be in the 5 MB range (sometimes more sometimes less) between the generations.
    12. After doing a 'Mark generation' for about 5 times, simulate a low memory warning (Simulator -> Hardware -> Simulate Memory Warning). 
You'll see overall memory footprint going down, but even for the earlier generations the growth remains more or less equal. This growth is mostly due to non-object

    Steps to reproduce with the demo app on a device
    1. Run the modified demo project on your device (ideally a bit older device, like iPhone 5).
    2. Open up a lot of big apps (memory hogs) like Facebook, some other navigation apps, etc.
    3. Then open the demo app, tap 'Navigation UI' and start driving.
    4. Sometimes after 5 minutes, sometimes after 3 hours, the app will crash

    Now, I'm not sure about the behaviour of the framework when a low memory warning is received, but I do know that the 'cleanup' is not always sufficient to prevent the app from crashing. As I said I am quite certain that my own code does not contain any substantial leaks because the difference in memory footprint of my app compared to the demo app always stays around the 15MB, which it initially also was, and there were no crashes when running 2.5.1 with light maps.

    I've already tried this:
    mapView?.settings.showStreetBadges = false
    mapView?.settings.showStreetNamePopUps = true
    mapView?.settings.showHouseNumbers = false
    mapView?.settings.poiDisplayingOption = SKPOIDisplayingOption(rawValue: 0)
    mapView?.settings.showOneWays = false
    But that didn't seem to effect the footprint nor cleanup.

    So, basically I'm looking for a solution to manage the frameworks memory footprint (more specifically the in memory map tiles cache) (and of course if there are leaks/abondoned memory in the framework they would ideally have to be fixed.) For example a way to set the the map tiles cache (in memory) to a maximum size, or, to have more influence on the 'clean up' method that's executed when a low memory warning is received (i.e. clean up more from the cache).

    I've asked this question already on Stack Overflow, where I was pointed to SKTilesCacheManager, but as I understand it that's only to manage the cashing of map tiles on DISK, not in memory.

    Is there a way to manage the frameworks memory footprint? If not, are there any plans to create this? Or perhaps better, to create a more dynamic and proactive way to manage to map tiles cache in memory, so that the app acts before ever receiving the low memory warning?
    And, are there any other things I could try perhaps?
    Last edited by guidove; 14.03.2017 at 00:59.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts