Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7531461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:10:40+00:00 2026-05-30T05:10:40+00:00

In my appDelegate I am using LocationManager : – (void)locationManager: (CLLocationManager *)manager didUpdateToLocation: (CLLocation

  • 0

In my appDelegate I am using LocationManager :

- (void)locationManager: (CLLocationManager *)manager
    didUpdateToLocation: (CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{

    float latitude = newLocation.coordinate.latitude;
     strLatitude = [NSString stringWithFormat:@"%f",latitude];
    float longitude = newLocation.coordinate.longitude;
    strLongitude = [NSString stringWithFormat:@"%f", longitude];
    [self CheckOperation];

}  

strLatitude and strLongitude are global strings. This is absolutely fine. Even on analyzing the application I don’t get any memory leak. But when I profile my application I receive a memory leak at

strLatitude = [NSString stringWithFormat:@"%f",latitude];  

and

strLongitude = [NSString stringWithFormat:@"%f", longitude];

of 32 bytes.

How can I fix that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:10:42+00:00Added an answer on May 30, 2026 at 5:10 am

    Are you sure you’re seeing a leak and not simply just an allocation?

    If you do actually have a leak here then there are some potential suspects:

    Are you using ARC? If not, here are some possible problems:

    • Are you releasing it in dealloc?

    • If this method gets run more than once, you aren’t releasing the last value before you reassign it.

    • If you’re not using copy semantics, and you’re passing this string reference off to someone else, and they aren’t properly releasing it, you’ll also get a backtrack to this line.

    EDIT:

    (Per the comments below)

    You should realize that stringWithFormat: is allocating a string and queuing up an autorelease on it… so you need to retain it somewhere.

    I assumed you were doing this somewhere because you aren’t getting an “EXC_BAD_ACCESS” – but rather, supposedly, a leak.

    You shouldn’t be leaking an autoreleased object unless you’ve retained it somewhere (hence the assumption).

    Given you need to be retaining it somewhere, my above suggestions are valid – each retain needs a matching release.

    I do agree that you should be using properties for these strings.

    It’s simple to convert them – and takes care of a lot of things for you.

    In your Interface:

    @property (nonatomic, copy) NSString * strLatitude; 
    

    In your Implementation:

    @synthesize strLatitude;
    

    To assign:

    self.strLatitude = ...
    

    (the “self.” part is important)

    And make sure you set that to nil in dealloc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Tableview on AppDelegate That calls a SecondView (dvController) when DidSelectRowAtIndexPath using:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MaSystemGuiAppDelegate *appDelegate = (MaSystemGuiAppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.deneme
I have an Obj-C method similar to this: -(void)getUserDefaults:(BOOL *)refreshDefaults { PostAppDelegate *appDelegate =
In my UIViewController's initWithNibNameOrNil , I call: locationManager = [CLLocationManager new]; to create the
How to use AppDelegate in other ViewController and What is the use of using
I am using cocos2d 0.99.4 and Xcode 4.0. so, I changed my AppDelegate in
When creating a new project (universal iPhone/iPad) using Core Data, there's the usual appDelegate
In my AppDelegate I am using the appearance proxy to make custom UI: //Setup
I am trying to integrate AdWhirl into my iPhone app using an AppDelegate singleton
I am using this in my appdelegate's applicationDidFinishLaunching: method to make sure the iPhone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.