Message from debugger: Terminated due to memory issue
<p>My app working with <code>Geojson</code> file. I use <a href="https://www.mapbox.com/ios-sdk/examples/line-geojson/" rel="noreferrer">MapBox SDK</a> to add <code>MGLPolyline</code> to map. But the problem is my file too large, so that the app crash and got the error: <code>Message from debugger: Terminated due to memory issue</code>. I faced with <strong>66234</strong> objects at first loop. I tried to chunk the array to new array but not success. Please help me to solve the prolem. Here is my code for draw on map and here is my <a href="https://github.com/nhatlee/GeoJsonLocation" rel="noreferrer">test project on github use Xcode 8.1</a> <strong>If have any different 3rd party which can solve my prolems is welcome too</strong>:</p>

<pre><code>func drawPolyline() {

    // Parsing GeoJSON can be CPU intensive, do it on a background thread
    DispatchQueue.global(qos: .background).async {
        // Get the path for example.geojson in the app's bundle
        let jsonPath = Bundle.main.path(forResource: "KMLMAPNew", ofType: "json")
        let jsonData = NSData(contentsOfFile: jsonPath!)

        do {
            // Load and serialize the GeoJSON into a dictionary filled with properly-typed objects
            guard let jsonDict = try JSONSerialization.jsonObject(with: jsonData! as Data, options: []) as? Dictionary&lt;String, AnyObject&gt;, let features = jsonDict["features"] as? Array&lt;AnyObject&gt; else{return}

            for feature in features {
                guard let feature = feature as? Dictionary&lt;String, AnyObject&gt;, let geometry = feature["geometry"] as? Dictionary&lt;String, AnyObject&gt; else{ continue }

                if geometry["type"] as? String == "LineString" {
                    // Create an array to hold the formatted coordinates for our line
                    var coordinates: [CLLocationCoordinate2D] = []

                    if let locations = geometry["coordinates"] as? Array&lt;AnyObject&gt; {
                        // Iterate over line coordinates, stored in GeoJSON as many lng, lat arrays
                        for location in locations {
                            // Make a CLLocationCoordinate2D with the lat, lng
                            if let location = location as? Array&lt;AnyObject&gt;{
                                let coordinate = CLLocationCoordinate2DMake(location[1].doubleValue, location[0].doubleValue)

                                // Add coordinate to coordinates array
                                coordinates.append(coordinate)
                            }
                        }
                    }

                    let line = MGLPolyline(coordinates: &amp;coordinates, count: UInt(coordinates.count))

                    // Optionally set the title of the polyline, which can be used for:
                    //  - Callout view
                    //  - Object identification
                    line.title = "Crema to Council Crest"

                    // Add the annotation on the main thread
                    DispatchQueue.main.async {
                        // Unowned reference to self to prevent retain cycle
                        [unowned self] in
                        self.mapboxView.addAnnotation(line)
                    }
                }
            }
        }
        catch
        {
            print("GeoJSON parsing failed")
        }
    }
}
</code></pre>

<p><strong>EDIT:</strong>:@Alessandro Ornano and @fragilecat thanks so much. But those solutions still cannot solve the terminate of the app on iPad. I think it so hard to change the current code to get it to work properly, because the data is so large. I think I will need another solution that works with big data. Like chunking the array into the small arrays then loading them by queue. But I don't know how to start :(</p>

<p>I send an email to the support team at MapBox, asking for suggestions.</p>