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

  • SEARCH
  • Home
  • 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 5972757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:42:12+00:00 2026-05-22T20:42:12+00:00

My application uses GPS and assigns an NSNumber instance variable every time the GPS

  • 0

My application uses GPS and assigns an NSNumber instance variable every time the GPS is updated and in my last bit of testing before release, I’ve discovered that it leaks a lot. I’m fairly certain I know which lines are contributing to the leak, but I can’t figure how to solve it.

latitude = [[NSNumber numberWithFloat:[[coordinates objectAtIndex:0] floatValue]] retain];

This line is in my GPS update method and is run regularly. Latitude is an instance variable, and when I remove the retain, I can no longer access the variable in the other methods I need. I have the variable released in the dealloc method, but that doesn’t seem to do anything.

I understand the alloc-release paradigm, but I’m still not sure how to fix this.

  • 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-22T20:42:13+00:00Added an answer on May 22, 2026 at 8:42 pm

    Before setting it, you must release the previously retained value. Otherwise, when you assign the new pointer, the previous object which is released has nothing referencing it and it can never be released.

    To do this easily, I recommend setting it as a @property and using self.latitude = [NSNumber numberWithFloat:[[coordinates objectAtIndex:0] floatValue]];. Notice that the retain is no longer used in the assignment. This is assuming your property is set up with the retain flag, and retains it for you.

    I.e.

    @property (nonatomic, retain) NSNumber *latitude

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

Sidebar

Related Questions

My application uses GPS updates while it is running and I would like that
Our application uses a large product database that is updated once a day. Updates
My application uses the Outlook object model. Outlook is an out-of-process COM server. Before
I am making a application that uses the GPS receiver. The application will work
The application that I have in the works uses GPS data to mark files
In my android application which uses GPS, I have UI elemnts that should blink
I have an iOS application that uses GPS for Location Services. A user would
I installed an application from app store that uses gps. I have only put
I made a small test application that uses the GPS module. To test it,
My application uses loads of Java threads. I am looking for a reliable understanding

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.