IOS 13.4: Outrageous consumption of memory of MKPolygon

  • The memory consumption of MKPolygon has skyrocketed in IOS 13.4, making apps that make use of lots of MKPolygons crash because of out of memory condition.
  • This only happens with REAL DEVICES and NOT IN THE SIMULATOR.
  • The same sample app I link here, when run in an IOS prior to IOS 13.4 device consumes 89.6 Mb, but run in IOS 13.4 consumes 1.29 Gb !!!!


https://github.com/vmalonso/TestMKPolygon


This needs a fast fix. Filed bug report n. FB7640504

Replies

While you wait for your bug to get some attention, you may want to look at MKMultiPolygon and MKMultiPolygonRenderer if your rendering is similiar for each item.


Somthing like:


func drawPolygons() {

        if #available(iOS 13.0, *) {
            let multiPolygon = MKMultiPolygon(arrayPolygons)
            mapView.addOverlay(multiPolygon)

        } else {
            mapView.addOverlays(arrayPolygons)
        }

        centerMap()
    }


and:


    func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
          
            if #available(iOS 13.0, *) {
                let renderer = MKMultiPolygonRenderer(overlay: overlay)
                renderer.fillColor = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 0.5)
                return renderer
            } else {
              // Fallback on earlier versions
                let renderer = MKPolygonRenderer(overlay: overlay)
                renderer.fillColor = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 0.5)
                return renderer
          }
        
       // return renderer
    }



-Mark

Thank you for the answer !!!


It seems to work. Unfortunatelly in my case not all the polygons have the same colors, just the test project I uploaded to Gihub. And I have to edit, move, etc... So, not a viable solution for me to have to draw all of them each time I modify one of them. I am afraid I will have to wait for the fix of the bug.


After a more deep test I have to rule out this solution. It is very slow. Apple should go back to the IOS 13.3 implementation.


Again, thank you Mark.

Not fixed in IOS 13.5 beta 3 yet

Still not fixed in iOS 13.6
IOS 14.4 and not fixed yet :-( !!!!
Looks like other maps platforms do not have this issue and seem to be more responsive with bug fixes at this point. Since it has been a year since this issue came out, it would probably be easier to move to a different platform like mapbox.