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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:55:37+00:00 2026-05-24T21:55:37+00:00

I am new to Objective C. I have a small doubt on memory allocation.

  • 0

I am new to Objective C. I have a small doubt on memory allocation.

If we declare & allocate memory for a NSArray like this:

NSArray * arr = [[NSArray alloc]init];

how much memory will be allocated for the array arr?

  • 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-24T21:55:38+00:00Added an answer on May 24, 2026 at 9:55 pm

    Hmm. If you really meant NSArray, then the array will be empty, no elements will be stored in it, hence only a small amount of memory is needed that would be needed for any Objective C object anyway. (The exact amount of memory is an implementation detail). But an empty NSArray that cannot be modified is not of much use, so I guess you meant NSMutableArray. For NSMutableArray, the array will be empty initially, but it may still allocate some extra memory (and it is very likely that it will) because Objective C expects the array to grow and it’s easier to add new elements to the array if there is already some memory allocated on top of what is strictly needed. The exact amount of extra memory allocated is also an implementation detail.

    If you want to ensure that your array takes up as little memory as possible, you can use [[NSMutableArray alloc] initWithCapacity:x] where x is the maximum number of elements you intend to put in the array. It will still have zero size but Objective C will assume that you are going to add x elements to it sooner or later hence it allocates a backing store that is enough for x objects.

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

Sidebar

Related Questions

I am new to Objective-C and I have no clue why this code is
I'm pretty new to Objective-C and i have lots of troubles with memory management
Im new to objective-c Lets assume I have a string such as this NSString*
I'm new to objective-c and at the moment developing a small application. I have
I am new to the whole iPhone SDK and objective C, but have managed
I'm new with Objective-C, so there probably is a simple solution to this. I
I'm new to objective-c and would like to know the best practice for importing
I have a brand new Objective-C class called test . The test class has
I'm new to objective-c and have been wondering what's the point of creating properties?
I'm a little new to objective-C but have run across a problem that I

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.