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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:14:50+00:00 2026-06-05T01:14:50+00:00

Take for example NSMutableArray: NSMutableArray* a1 = [[NSMutableArray alloc] initWithCapacity:10]; NSMutableArray* a2 = [NSMutableArray

  • 0

Take for example NSMutableArray:

NSMutableArray* a1 = [[NSMutableArray alloc] initWithCapacity:10];
NSMutableArray* a2 = [NSMutableArray arrayWithCapacity:10];

Under manual reference counting, the second line returned an autoreleased object. Now with ARC enabled, does the second return an __autoreleasing object and the other does not? What’s the difference, if any?

What if the class I’m initializing is a custom class which has been converted to ARC, where the conversion removed the autorelease message from the initializer:

MyClass b1 = [[MyClass alloc] initWithNumber:1];
MyClass b2 = [MyClass myClassWithNumber:1];

// MyClass implementation of myClassWithNumber
+(id) myClassWithNumber:(int)num
{
    return [[self alloc] initWithNumber:num];
}

Is there any difference between b1 and b2, and is it any different from how a1 and a2 are created?

  • 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-06-05T01:14:52+00:00Added an answer on June 5, 2026 at 1:14 am

    LearnCocos2D,

    ARC does not change calling conventions. If your method’s name would return an autoreleased object under MRR, then it will return one under ARC. ARC is a local optimization to each method. That is why you can mix and match MRR and ARC code in the same project. (Even categories can have different memory management methods.)

    In your second code example, ARC adds an autorelease to the returned value, if called for. Why is it the last thing? Because ARC is partially about minimizing your memory footprint. Hence, it wants to manage the lifetime of every object created in the method. The only object created in the method that will ever be autoreleased is the returned value.

    In general, ARC is supposed to be minimally invasive to your code. Basically, you are turning over responsibility for memory management to the compiler. (Where it always should have resided anyway.) Problems with ARC surface with bringing toll-free bridged CF objects into Objective-C code. Most times the toll-free bridged items are handled with the __bridged storage modifier. Apple’s documentation is quite good around ARC. The Clang documentation is precise.

    Don’t sweat ARC. As is the case with modern compilers, it will probably manage memory better than you do.

    Andrew

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

Sidebar

Related Questions

How do I take for example 25 photos in one second at low resolution?
Take for example the following: Project *project = [[Project alloc] init]; project.title = @MyProject;
Take this example code (ignore it being horribly inefficient for the moment) let listToString
Take for example an application which has users, each of which can be in
Take for example the following regex match. preg_match('!^publisher/([A-Za-z0-9\-\_]+)/([0-9]+)/([0-9]{4})-(january|february|march|april|may|june|july|august|september|october|november|december):([0-9]{1,2})-([0-9]{1,2})/([A-Za-z0-9\-\_]+)/([0-9]+)(/page-[0-9]+)?$!', 'publisher/news/1/2010-march:03-23/test_title/1/page-1', $matches); print_r($matches); It produces the
Take the example I have setup at http://jsfiddle.net/vEF6y/ Click on the 'add item' button
Take this example Proc: proc = Proc.new {|x,y,&block| block.call(x,y,self.instance_method)} It takes two arguments, x
Lets take this example. I have a AView which is bound to AViewModel. AView
I take an example from Fortran 95/2003 explained by Metcalf et al, since m
Let's take for example a small social network site. One of modules are also

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.