Select to view content in your preferred language

AGSGraphicsLayer eat up memory in SDK 10.1.1

1239
8
06-09-2013 08:25 PM
JamesZhang
Deactivated User
I create 10 AGSGraphicsLayers and add to the MapView. It works well in SDK 2.3.2 on the iPad.
Today I upgrade the SDK to 10.1.1. It occupied nearly 600MB when I create 10 AGSGraphicsLayers on App starting. Then it crashed because it received high memory warning.

How to solve my problem? How to optimize the 10 layers?
Addition, my app has ARC(auto-reference-couting) on.

Thank you!
0 Kudos
8 Replies
DiveshGoyal
Esri Regular Contributor
Are you using Update 1 for the 10.1.1 release?
We improved memory management in that update. Please download it and let us know how it works out.
0 Kudos
DinaLi
by
Deactivated User
Are you using Update 1 for the 10.1.1 release?
We improved memory management in that update. Please download it and let us know how it works out.


I installed Update 1, but I'm still experiencing the low memory warning problem, and my app crashes especially when the user zooms and pans. It uses two ESRI maps and an ArcGIS map service that we created. Help!
0 Kudos
JamesZhang
Deactivated User
Are you using Update 1 for the 10.1.1 release?
We improved memory management in that update. Please download it and let us know how it works out.


Thanks! I'll try it out ..
0 Kudos
DiveshGoyal
Esri Regular Contributor
Dina,

Can you share with us the services you're using, or a repro test app that'll help us investigate the problem?
I can email you a secure link to upload your information to, but I'll need your email address.

_
D
0 Kudos
JamesZhang
Deactivated User
Thanks! I'll try it out ..


Thanks, it works.
0 Kudos
DinaLi
by
Deactivated User
Dina,

Can you share with us the services you're using, or a repro test app that'll help us investigate the problem?
I can email you a secure link to upload your information to, but I'll need your email address.

_
D


Thanks very much for offering to assist. The code is available here: https://github.com/dinali/SNAPatlas.git. This is a proof-of-concept app to see if we can display some of our ESRI maps together in a single mobile app. The user can choose different maps. The problem is that the app runs fine on the simulator (all the features work), however, I've tested it on an iTouch (4th generation) and iPad 2 (both running iOS 6+) and I'm getting the didReceiveMemoryWarning exception and then the app crashes. I used the Instruments tool and the app uses a lot of memory.

Specifically, the problem is with the code to change the base map - see the "Change the Map" / MapPickerViewController code. The app crashes after the user changes the map. I need to supply the URL for different maps (not just reset the layers). I thought maybe I could cache the two ESRI maps and only change my dynamic map, but I couldn't figure out how to do that. If I include 

[self.mapView removeFromSuperview];

in the MainViewController's - viewDidDisappear method, the app will not crash. This raises other problems, however, because the mapView is no longer available for the Layers feature (TOCViewController) that is displayed using presentViewController. I don't know if there's a way to add the mapView back to the superview somewhere.

I'm new to iOS programming, so you'll notice that I've relied heavily on the ESRI samples. Any advice would be appreciated.
0 Kudos
DiveshGoyal
Esri Regular Contributor
In taking a look at your code, i noticed that you create a new instance of the MainViewController everytime the user changes the map. So if a user switches the map 5 times, you will have 6 MainViewControllers alive in memory, each containing its own hierarchy of view objects including a map view and its layers. This is not very efficient.

It is better if you reuse the single instance of MainViewController by popping the MapPickerViewController from the navigation stack. You should use the viewWillAppear method in MainViewController to reset the map and add new layers to reflect the map that the user picked. If many of the layers are common between the maps,  you don't need to reset the map, you can individually remove & add layers.
0 Kudos
DinaLi
by
Deactivated User
In taking a look at your code, i noticed that you create a new instance of the MainViewController everytime the user changes the map. So if a user switches the map 5 times, you will have 6 MainViewControllers alive in memory, each containing its own hierarchy of view objects including a map view and its layers. This is not very efficient.

It is better if you reuse the single instance of MainViewController by popping the MapPickerViewController from the navigation stack. You should use the viewWillAppear method in MainViewController to reset the map and add new layers to reflect the map that the user picked. If many of the layers are common between the maps,  you don't need to reset the map, you can individually remove & add layers.


Thank you very, very much for taking the time to examine my code, Divesh. I am re-designing the app based on your advice. I am not encountering the didReceiveMemory warning issue any more, so this was clearly a coding issue and not an SDK performance problem.
0 Kudos