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

The Archive Base Latest Questions

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

if I release a variable more than it should be, would that be a

  • 0

if I release a variable more than it should be, would that be a problem? I cannot determine the retain count ahead of time.

  • 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-16T05:07:40+00:00Added an answer on May 16, 2026 at 5:07 am

    Foreword

    The retain count should be considered more of a theoretical offset. You should never care about what the value currently is, just how your actions will offset it. For example, when you add an object to an array, you have offset its retain count by +1, and when you remove an object from an array, you have offset its retain count by −1. When you’re completely done with an object, its retain count offset (relative to you) should be 0. What its retain count actually is does not matter, as long as you fulfil your obligations to manage the object appropriately.

    Inspecting the retain count explicitly will often not show what you expect. This could be because of optimisations under the hood. Cocoa relies on the developer conforming to the memory management guidelines. Follow these very simple rules, and do not worry about the explicit value of retainCount.

    WRT the question

    Over-releasing an object (sending it too many release messages) can—and usually does—result in premature deallocation of that object. Any messages that get sent to the address where the deallocated object used to be will usually crash your application. The dumbed-down rules of thumb are:

    1. Sending a alloc, new, retain, copy (or any method with copy in its name) will give you an object with a retain count offset by +1.

    2. Sending release will offset that objects retain count by −1.

    3. Balance each +1 with a −1 and that’s it!

    Furthermore

    If you are developing a framework or library and you are returning objects to users of your framework, don’t try to prevent errors in their code by over-retaining objects. Their obligations are exactly the same as yours, and if they break your framework from poor memory management then that is a bug in their code, not yours.

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

Sidebar

Related Questions

This is probably a question that is more about object alloc/retain/release, but I'll use
I have an app (using retain/release, not GC) that maintains an NSArray instance variable,
i wonder if it's possible to define a variable/property of more than one type.
How can I create more than one label variable programmatically I tried following code
Given that a class and all its subclasses need no more than the default
Could someone translate this, into a syntax that uses the built in variables? \\myserver\builds\mybuild\Daily_20090525.1\Release\_PublishedWebsites\myWebsite
The release notes for Java NIO (in Java 1.4+) state that support for direct
I'm trying to create a release script that can be deployed on multiple databases,
I have a instance variable declared as a retain property & then I released
I am attempting to remove one more step in my application's release process by

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.