Despite using the much-loved MemoryHotFix community SO to deal with this issue, you should be sure that you don't have a strong link. As others have said, if you use (read instances) views that contain a link to the view controller in which they are located and the same view controller as the link to this view, you can get into a strong link loop.
Such a situation may block your deinit / dealloc methods, which make your cleanup unnecessary and useless.
As stated in the documentation :
You allow strong reference loops by defining some relationships between classes as weak or unpublished links, and not as strong links.
Therefore, do not forget:
- Check if your deinit (swift) / dealloc is actually called (if not, it could indicate a strong reference loop).
- In fact, nil delegates are MKMapView and LocalitionManager, as well as themselves.
Like this:
self.mapView.delegate = nil self.mapView = nil self.locationManager?.delegate = nil self.locationManager = nil
Proof
With that in mind, here is an example where one VC clicks another VC with MKMapView, each vertical red line means “clicking a new VC”, and each green line means “popping it”:

There is an initial setup (starting at 50 MB +/-), but a future push does not cause a memory leak, as shown. It is worth noting that this was recorded using a real device. I also tested it using a simulator, and the results were coherent, even though the initial setup was much higher (starting at 100 MB).
Hope you guys can fix this and you can also check your project for Strong link cycles that could harm your product in the future;)
source share