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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:35:30+00:00 2026-05-26T08:35:30+00:00

In most of the code that I’ve sen using autorelease, the object is ultimately

  • 0

In most of the code that I’ve sen using autorelease, the object is ultimately returned from the function.Clearly release cannot be called after this point and autorelease is the way to go. However in situations where the object is going to passed to another object that will retain it is using autorelease just as valid?

For example

-(void)foo
{
   SomeClass *someObject = [[[SomeClass alloc] init] autorelease];
   //Do some things
   self.someOtherClass.someProperty = someObject;
}

Is there any practical difference to releasing the object after it is assigned to someProperty:

-(void)foo
{
   SomeClass *someObject = [[SomeClass alloc] init]];
   //Do some things
   self.someOtherClass.someProperty = someObject;
   [someObject release];
}

Are there any situations where the later is more preferable to the former?

  • 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-26T08:35:31+00:00Added an answer on May 26, 2026 at 8:35 am

    Both are acceptable, but you are accouraged to use the release version to avoid memory spikes an other problems.

    It’s acceptable to release here because you can assume that the receiver of the object will retain it, if it needs if later. So you can safely release as soon as it’s given.

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

Sidebar

Related Questions

Here's a piece of code that takes most time in my program, according to
below i have a code that runs in most of my simple programs ..
The code below returns the 10 most recent entries to a MySQL database. That's
I've been working a lot with C# recently, and I've noticed that most code
I have code that imports from Excel sheets of a specified format. In one
I have loads of code that most need to be loaded BEFORE the other
I have got some code that gets the most frequent words and puts them
I have a piece of code that works on most browsers except the Android
I have wrote a code that can read an excel 2007 file using Microsoft
Essentially, I found an old piece of LINQ C# code that counted the most

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.