Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any performance penalty for using multiple CLLocationManager instances

I have at least two controllers in my app that currently use their own CLLocationManager instance. I'm curious however if using multiple instances actually imposes any additional burden on the phone - beyond the additional memory for the different instances.

Will the iPhone ping the GPS hardware multiple times, or does it use some sort of dispatch such that the hardware is abstracted and just forwarded to all listeners? I was about to write my own abstraction layer to handle multiple observers but wanted to check if there was any knowledge out there to suggest it's not necessary.

like image 760
Paul Alexander Avatar asked Sep 01 '10 01:09

Paul Alexander


1 Answers

I would say no, it would not be a problem or performance penalty. Having multiple instances of CLLocationManager in one app is no more costly than having multiple apps in the background all with CLLocationManagers. The OS configures the GPS/cell radios for minimum power use based on the combined requests of all the CLLocationManagers.

Be sure to stop location updates on all CLLocationManager instances when your app doesn't need it anymore (ie: in applicationWillResignActive:) so the GPS h/w can be turned off to save battery.

like image 98
progrmr Avatar answered Sep 17 '22 01:09

progrmr