I am using iOS Google Maps in my app. I've been looking for memory leaks as of lately as I noticed the Memory started spiking whenever I would zoom out. Both on simulator and my actual iPhone X device experience such memory spikes when zooming out. I am also zooming out because I am using the marker clustering feature.
I've done some research on different ways to detect memory leaks such as enabling sound actions on breakpoints and looking at Backtrace
tree for strong references. It seems that there is a strong reference when I configure my GMSMapView (Code below).
func configureMapView() {
guard let location = locationManager.location else { return }
let camera = GMSCameraPosition.camera(withLatitude: location.coordinate.latitude, longitude: location.coordinate.longitude, zoom: 16.5)
mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.isMyLocationEnabled = true
mapView.settings.compassButton = true
mapView.settings.rotateGestures = false
mapView.settings.tiltGestures = false
view = mapView
}
Xcode is pointing to this line that has a strong reference.
mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
Is this strong reference the reason why memory usage spikes up when zooming out? Also, not entirely sure how to fix this strong reference with Google Maps, any help would be appreciated!