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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:33:18+00:00 2026-05-27T08:33:18+00:00

If I do this- SomeObject* someObject = [[SomeObject alloc] init]; [[someObject release] release]; I

  • 0

If I do this-

SomeObject* someObject = [[SomeObject alloc] init];
[[someObject release] release];

I presume my program wouldn’t crash because the second over-release is acting on nothing.

Whereas

[[someObject autorelease] autorelease];

would crash because the object is released twice by being passed down the chain.

This is a matter of curiousity only, I guess I’ve never had a problem with it so far.

  • 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-27T08:33:19+00:00Added an answer on May 27, 2026 at 8:33 am

    (See this answer for an explanation what oneway does.)

    Your first example doesn’t even compile, as void != nil. But if you simply call release two times on an object that has a retain count of 1, it’ll for sure crash.

    As for why release returns void while autorelease returns id: The first says I don’t need this object any more, you may get rid of it. Thus, if it would return something and you would operate on it you’re likely to operate on a dead object. By contrast, autorelease more or less says “Soon I won’t be needing the object any more but let it stick around until I’m done with the current method.”

    So as you see they are similar in that they say I won’t be needing this object any more, but they differ in the time: release says “you can get rid of the object now“, while autorelease says “you may get rid of the object later“.

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

Sidebar

Related Questions

If I have something like this: SomeObject *obj = [[SomeObject alloc] init]; obj.someIvar =
Suppose I have this code: -(SomeOtherType*) getMyObject { SomeType someObject = [[SomeType alloc] init];
If i do this NsMutableArray* array = [[NSMutableArray alloc]init]; [array addObject:someObject]; someProperty = array;
If I get a NullPointerException in a call like this: someObject.getSomething().getSomethingElse(). getAnotherThing().getYetAnotherObject().getValue(); I get
I'm doing this query: SomeObject.objects.annotate(something=Avg('something')).order_by(something).all() I normally have an aggregate field in my model
If I do this: def foo(): a = SomeObject() Is 'a' destroyed immediately after
The MSDN documentation says that public class SomeObject { public void SomeOperation() { lock(this)
I have an object like this class SomeObject def initialize &block # do something
I have classes like this one: class SomeObject { public function __construct($param1, $param2) {
My code is doing things like this: for(SomeObject so : someObjects) { Blah b

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.