0

In my app I have a functionality to the log the GPS. I am using AGSSketch GraphicLayer to do the drawing with the points received from GPS/location manager.

I see that the memory allocations get mounted as the number of locations get increased. I used the instruments tool (comes along with Xcode) to know which objects leads to it. The tool shows that sketch layer is causing the jump in memory allocations.

Is there a way to avoid this. Few blogs suggested to update the ArcGIS sdk but that didn't help.

1 Answer 1

1

I managed to resolve the issue myself. Want to mention the changes I done, hoping that it might save time of others who face the same issue.

This is what was happening in my case: The GPS was giving the points on frequent basis and my code was drawing the points on sketch layer. All this execution was happening on a single thread. After drawing each point to the sketchLayer, the point is removed from memory (atleast my code does that). My observation is that the memory is not flushed instantly but added to the autorelease pool and which gets flushed at the end of the thread. so in my case until I ask the location manager to give me points, the thread was busy collecting the points and drawing to the sketch layer.

Fix: In order to draw the points to the sketch layer, I was iterating through the array of points received from location manager. I have introduced a autorelease pool in the array, thus each iteration would create a new pool and flush at the end of the iteration. This way my issue was resolved and it is not an issue of Sketch/graphic layer but my bad implementation :( However I am happy I learnt my mistake and corrected it :)

code snippet: pendingLocations is locations array from "- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations"

for (CLLocation *loc in pendingLocations)
            {
                @autoreleasepool
                {
                    //Do the drawing on sketch layer

                }

            }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.