I have a pretty simple application with several view controllers. The second view controller has MKMapView. It is configured correctly and works fine. The problem is that every time I load his view, the memory usage jumps ~ 30 MB and never returns, so every time I enter the view, he continues to jump and, in the end, becomes super high. I tried to remove the map display when I left the controller as follows:
override func viewWillDisappear(animated: Bool) { map.removeFromSuperview() }
but it does not affect memory. The map views delegate has its controller installed.
I tried checking for leaks with the Xcode tools, but didn't find anything.
Does anyone know how to fix this?
thanks
EDIT: Adding this seems to work:
func removeNastyMapMemory() { map.mapType = MKMapType.Hybrid map.delegate = nil map.removeFromSuperview() map = nil } override func viewWillDisappear(animated: Bool) { removeNastyMapMemory() }
source share