I included MKMapView in my project, but when I exit this controller, it cannot free memory. I ran into this problem in iOS 10, only I tested in iOS 9, it works fine.
I tried to free the memory using the code below, but it does not work.
let overlays = self.mapView.overlays
self.mapView.removeOverlays(overlays)
self.mapView.mapType = MKMapType.standard
self.mapView.showsUserLocation = false
self.mapView.removeAnnotations(self.containerView.mapView.annotations)
self.mapView.delegate = nil
self.mapView.removeFromSuperview()
self.mapView = nil
source
share