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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:20:25+00:00 2026-05-15T15:20:25+00:00

I was reading the Memory Management Guide for IPhone OS and I didn’ t

  • 0

I was reading the Memory Management Guide for IPhone OS and I didn’ t understand a point in the Autorelease Pools section Listing – 1 code example:

void main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSArray *args = [[NSProcessInfo processInfo] arguments];

for (NSString *fileName in args) {

    NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];

    NSError *error = nil;
    NSString *fileContents = [NSString stringWithContentsOfFile:fileName
                                       encoding:NSUTF8StringEncoding error:&error];

    /* Process the string, creating and autoreleasing more objects. */

    [loopPool release];
}

/* Do whatever cleanup is needed. */
[pool drain];

exit (EXIT_SUCCESS);
} 

It says that :

“…….Additionally, any autoreleased objects created in the context of the for loop (such as fileName) are released when loopPool is released even if they’re not explicitly sent an autorelease message.”

The point that I didn’t understand is how the fileName variable is included in the second pool(loopPool) but not the first one(pool). Isn’t the fileName created when the first pool is the top most pool in the pool stack ?

  • 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-15T15:20:26+00:00Added an answer on May 15, 2026 at 3:20 pm

    You are right. fineName is in the outer pool. If it’s like this in the docs, it’s a bug.

    Edit: Feel free to file a bug report at Apple’s radar system.

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

Sidebar

Related Questions

After reading the Memory Management Guide I am trying to get my head around
I am just reading through the Practical Memory Management guide. I am somewhat confused
I'm reading memory management rules to this point where it said - (void)printHello {
I was reading the apple documentation for memory management , and came across something
I have been reading different articles on memory management in preparing for how I
I am reading addresses in memory with the below code. It occurred to me
I am very new to Objective-C and was reading through memory management. I was
I was reading through Apple's doc of Basic Memory Management Rules. I came across
I'm fairly new to Objective-C, and am currently reading up on memory management. I'd
From reading the memory management docs in the SDK, I gathered that factory methods

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.