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 6842379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:05:36+00:00 2026-05-27T00:05:36+00:00

Instruments is reporting me a leak of a NSDate variable. But If I add

  • 0

Instruments is reporting me a leak of a NSDate variable. But If I add up the retains and releases it should be able to release I think, by the autorelease pool. Probably I’m counting wrong but I wan’t to make sure. Take a look at the RefCt.
If I [Class alloc] it should come up with a retain count of 1, then if I autorelease that object, it should be able to free, or is it not?

enter image description here

  • 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-27T00:05:36+00:00Added an answer on May 27, 2026 at 12:05 am

    Instruments adds up the retains and releases for you. That’s what the “RefCt” column shows you: The running total.

    If I [Class alloc] it should come up with a retain count of 1, …

    And indeed it does; that’s the first row in the list.

    … then if I autorelease that object, it should be able to free, or is it not?

    Autorelease isn’t an immediate -1; it causes a release later, and that’s the -1.

    So you have:

    1. Allocation: +1 (=1)
    2. Autorelease: 0 for now; causes a Release later (no change now, so still =1)
    3. Retain: +1 (=2)
    4. Release: -1 (=1)
    5. Retain: +1 (=2)
    6. Retain: +1 (=3)
    7. Release: -1 (=2)
    8. Release: -1 (=1)

    Note that one of the three Releases is the one caused by the Autorelease. Only then is -1 incurred.

    The object needs another release in order to be deallocated. Until that happens, it won’t.

    And yes, it is possible for an object that has enough outstanding autoreleases to kill it when they come due to be retained before that happens and thereby be kept alive. I saw this happen once with an object that I was under-retaining, but that was the value of a property being used by a Binding; the Binding retained the value and so kept it alive even after I had autoreleased my own last ownership of it.

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

Sidebar

Related Questions

Instruments tools says this is a leak, any ideas? I release the variable object
Instruments tells me there's a mem leak in this code, but I can't seem
Quick question, Instruments is reporting a leak here... MyViewController *myVC = [[MyViewController alloc] initWithNibName:@myView
Using Instruments, I keep on getting pointed to a memory leak with a UIImage.
I am trying to locate leaks using instruments, but the leaks I see there
I tracked down a memory leak with instruments. I always end up with the
Using Instruments on the device it detects a 3.50 KB memory leak using Apple's
Instruments shows me that I have a leak in the following code: CGContextMoveToPoint(c, startPoint.x,
I'm getting an instruments Memory Leak with this iPhone 3.0 SDK code. I'm using
Instruments can be used to check the short-term memory usage of an app, but

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.