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

I am just reading through the Practical Memory Management guide. I am somewhat confused
I've been reading an apple document on Memory Management and am now a bit
After reading: Memory management of a view controller in Objective-c and Does UIView's addSubview
I'm certain that I'm missing some fundamental understanding of iOS memory management and, despite
I've been reading about autoreleasepool but there is a point which is a bit
I have been going back through my app trying to handle all the memory
I am reading records from the AddressBook using the Apple provided API. I am
I'm creating a UIView similar to Apple's Scrolling example and I have a question
I'm trying to write this down as concisely as possible, but it's not easy
Although the title is part of my question, the second part won't be as

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.