1

I am working on a project where I need ViewController to show Google Map to indicate the location of Property and many other objects like table view and collection view to show JSON Data on the same view controller.

Problem: This ViewController taking memory near about 72 MB and when I debug the code to check why it's taking much memory then I have observed Google Map is the reason. If I removed the Google map then its only took 15 MB space, however, I have created other view controller in which I took only UIView and gave it type GMSMapView and when I run the code it was taking near 70 MB memory.

Is it normal behavior of google map? As I haven't written any code just assigned the type GMSMapView to UIView and it was taking a huge memory.

I need a solution to decrease this memory problem. Can anybody suggest how we can do that in the case of Google map?

Please note: I haven't written any code for Google MapView, just assigned the GMSMapView type to UIView and memory jump to near 70 MB and above.

Amanpreet
  • 1,301
  • 3
  • 12
  • 29
  • Make google map outlet as weak – Sarabjit Singh Sep 06 '18 at 06:07
  • @SarabjitSingh Its already weak. – Amanpreet Sep 06 '18 at 06:14
  • "just assigned the GMSMapView type to UIView and memory jump to near 70 MB and above" - Can't confirm your experience on that, try to find where you might be instantiating it. I have several views and xibs doing that, no memory impact until they are instantiated. Once 1 is instantiated though, memory impact is around 50MB and 20MB of it never goes away, even if all GMSMapViews are dealloced. These 20MB are "cached/internal" things that Google SDK just keeps in memory for "in case". Reported as a bug to Google iOS Map SDK issue tracker. You can star my issue to raise its priority to Google :). – Stanislav Dvoychenko Sep 07 '18 at 06:16

1 Answers1

2

I used it my app( online taxi app ) and I think it's normal but for making the memory usage lesser you can remove GMSMapView when viewController didDisappear

override func viewDidDisappear(_ animated: Bool) {
        mapView.clear()
        mapView.removeFromSuperview()
        mapView = nil
       }

it causes your app uses less memory

Alireza12t
  • 377
  • 1
  • 4
  • 14