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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:35:05+00:00 2026-05-11T20:35:05+00:00

Im pretty new to objective-c programming and releasing of objects is my greatest headache.

  • 0

Im pretty new to objective-c programming and releasing of objects is my greatest headache.
I’m always doubting on what need to be released, and my times I’ve end up releasing the wrong variable and getting a BAD EXEC crash.
I’ve read apple’s guide on memory management, but I cant always go from their examples to my code.

One of these situations is my singletons (Im a big Singleton guy).

I have one define as this:

static Configuration* _instance;

+(Configuration*)getInstance{
    if (_instance == NULL){
        _instance = [Configuration alloc];
        [_instance initConfig];
    }
    return _instance;
}

In my code I use it like this:

//Store configuration       
Configuration* conf = [Configuration getInstance];  
conf.userName = self.userName.text;
conf.cellPhone = self.phoneNumber.text;

Do I need to release the “conf” variable?

When should I release the _instance?

Since Im running this code on iPhone, what happens with the vars I don’t release? will they affect the iPhone performance?

  • 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-11T20:35:05+00:00Added an answer on May 11, 2026 at 8:35 pm

    When you created the Configuration instance with “_instance = [Configuration alloc]; [_instance initConfig];” it had a retain count of one from the alloc call. If you were to release conf after “conf.cellPhone = self.phoneNumber.text;” then it would be deallocated at that point.

    When you first create an object with alloc, or copy, or mutableCopy it will have a retain count of 1. Each call to retain increases that retain count by one. Each call to release decreases that retain count by 1. Calling autorelease just means “Call release for me later”, so if retains and releases are like checks, autorelease is like future dating a check.

    Your code that accesses the Configuration singleton does not retain it, copy it, or mutable copy it, so it should not release it.

    As your code is written now, the Configuration object will never be released, and will live for then entirety of the applications life, which is typically what you want with a singleton.

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

Sidebar

Related Questions

I pretty new to Objective-C (and C itself) and need to consume a NSData
First, let me say that I'm pretty new to Objective-C and iOS programming in
I am pretty new to iPhone/Objective-c programming. I'm struggling with an issue that doesn't
I'm pretty new to all that iOS stuff and Objective C- Programming. Since I'm
I really need help here. I'm pretty new to iOS/Objective-C so sorry if the
I'm pretty new to objective-C (and C in general) and iPhone development and am
This is probably a completely stupid question, but i'm pretty new at objective-C and
I'm pretty new to Objective-C so hopefully this all makes sense. I've downloaded images
I'm pretty new to objective c, and having some basic problems. I wrote a
I'm pretty new to objective C started a few days ago... I want to

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.