clusterlayer-plugin-ios icon indicating copy to clipboard operation
clusterlayer-plugin-ios copied to clipboard

Memory issue

Open ivanimr opened this issue 8 years ago • 6 comments

Hi @nixta,

Are you aware of any memory issues with this library? On every call of method +(AGSClusterLayer *)clusterLayerForFeatureTableLayer:(AGSFeatureTableLayer *)featureTableLayer the memory footprint of my app is increased by 9-10 megabytes which causes memory issues after multiple calls of this method. This method is called in our app whenever an item has been added to the map view - we refresh the map view and re-add all the layers, including the newly created clustering layer. I've debugged this library and memory usage increases after -(void)addItems:(NSArray *)items has been called in method -(void)rebuildClusterGrid in -(void)dataLoadCompleted of -(void)featureLayerLoaded:(NSNotification *)notification. Hope you can help me out.

Kind regards, Ivan

ivanimr avatar Jan 05 '18 12:01 ivanimr

Hi @ivanimr. I wasn't aware, but to be honest I hadn't profiled this for memory use.

It's also been a loooong time since I've looked at this, so it might take me a while to spin up and get to figuring it out. But thanks for the info - that'll help a lot.

nixta avatar Jan 05 '18 20:01 nixta

@ivanimr: Could you give me a little more info please?

  1. Are you clustering feature layers or a graphics layer?
  2. Where are the layers coming from? ArcGIS Online, your own server, or perhaps a Geodatabase locally on the device?
  3. Could you give me an indication of the number of layers and the number of features you're clustering here?
  4. Do you see the same pattern with the default sample app? I see a small increase, but nothing huge, however the profile of the sample app is to just add and cluster one or two layers, so quite different to your usage.

Just trying to get as much info as possible so that I can reproduce first before spending time following my way down the wrong path.

Thanks!

nixta avatar Jan 09 '18 21:01 nixta

@nixta: Of course, I'll provide you with any info you need for this issue.

  1. I am using the newly added method clusterLayerForFeatureTableLayer for clustering a feature table layer (AGSFeatureTableLayer).

  2. The feature table layer is created from a feature table in the local Geodatabase so it's offline data.

  3. We are clustering only one feature table layer. This layer had about 400-500 features that have to be clustered.

  4. I haven't tested the sample app still, not sure if it would provide me any info though as I'm clustering the Geodatabase layer and it has a lot of features. I could test it out if you think it's viable.

Thanks a lot!

ivanimr avatar Jan 10 '18 12:01 ivanimr

Thanks @ivanimr.

I think taking the sample and just dropping your geodatabase layer in there in place of the demo layer to see if you still see the impact would be useful.

Separately, and hopefully I can avoid asking for this, would you be able to share the .geodatabase file if need be?

nixta avatar Jan 10 '18 17:01 nixta

@nixta I would be able to share the .geodatabase file with a few modifications but I think I'm able to reproduce it with the geodatabase file from the sample app too with some code changes. Let me explain you our workflow first. The iPad user has an interface in the app for manually adding features (he selects the location and enters some other info). This newly created feature is saved to the feature table of the .geodatabase file. In order for that feature to appear on the map along with already shown features, we first remove map layers (feature table layer and clustering layer) and then create a new feature table layer from the feature table in the .geodatabase file, setup the clustering layer again and add them both to the map view. Please let me know if that's not a good approach.

I've simulated the same behavior in the sample app. I've attached the slightly edited controller of the sample app. AGSSampleViewController.m.zip

Feature and clustering layer are added with a name and also removed with the same name in this file. For testing purposes, I've changed the - (IBAction)toggleClustering method to no longer toggle clustering but instead to remove those two layers and add them again, similar as it is in our app. On toggling the "Clustering Enabled" in the sample app with this controller, you can see the memory footprint increase. Hope this helps!

ivanimr avatar Jan 11 '18 16:01 ivanimr

Hi @ivanimr. Really sorry that I dropped the ball on this! New job got the better of me.

I'm working on a new version for Runtime 100.x. See #22. Would that be of use to you?

Otherwise, did you manage to improve the memory issue at all?

nixta avatar May 30 '19 13:05 nixta