10 MB memory leaks

1599
1
07-29-2016 04:46 AM
MaximNikolaev
New Contributor

Issue: Huge memory leaks are observed using mapView.locationDisplay.startDataSource() in Swift.

It's happens when mapView.locationDisplay.stopDataSource() is called or not. It is called  from the UIViewController method - viewWillDisappear() or in other places with less frequency. Every time it eats about 10 MB.

Environment: XCode Version 7.3, Swift version 2.2, hardware - iPhone 6, iOS 9.3.2, the issue reproduces on the simulator, the issue reproduces for debug and release build. Any ideas to resolve this issue?

Code example is attached. It's modified webmap example from Esri. startDataSource() is called by pressing the button on the map view. Stop is called by pressing on the button again or by pressing Back in the navigation bar.

The lines of codes below were added. It's helps in the first case to prevent memory leaks. If user wants go back memory leaks are occurred.

            webmap.unbindFromMapView()

            webmap.delegate = nil

photo_2016-07-29_14-23-58.jpg

Tags (1)
0 Kudos
1 Reply
DiveshGoyal
Esri Regular Contributor

Maxim, I haven't looked at your app (thanks for that by the way), but I want to provide a word of caution : don't trust all the leaks reported by Instruments. I have personally seen some spurious reports for code that I knew did not leak. A more reliable way to find leaks and unbounded memory growth is by doing generational analysis using the Allocations profile in Instruments.

If what leaks is reporting is indeed true, then you would be able to easily observe the app's memory footprint (either in Instruments memory profile tool, or an XCode debug guage) increase significantly every time you start-stop-start-stop the location display. Can you confirm if you see that?

0 Kudos