0

I have UIViewController with GMSMapView (connected from storyboard) like this

@IBOutlet weak var map: GMSMapView!

in

override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
        self.map.delegate = nil
        self.map.clear()
        self.map.removeFromSuperview()
        self.map = nil
          
    }

and also I have

deinit {print "DEINIT ME"}

Deinit works - I see print message.

I have to load and unload this viewcontroller many times during app works. Dismiss - this is presented view controller. And each time I use it - in memory adds new GMSMapView. Ten times I use controller - ten GMSMapView objects will be in memory graph and so this connect with huge memory leak.

How can I unload GMSMapView from memory when I dismiss this viewcontroller?

tePoloN
  • 37
  • 8

1 Answers1

0

The code in your viewDidDisappear is useless. The map view is already defined as weak, which means it will release from memory when the view controller de-initializes. Check your memory graph if the view controller is still there after you de-initialize it. If the view controller is still there, then some other property in your view controller is holding a strong reference to the view controller, and has nothing to do with the map. Otherwise this might be a problem in the GMSMap framework.

Tad
  • 889
  • 9
  • 23