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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:08:47+00:00 2026-05-21T03:08:47+00:00

I can’t have a big NSAutoreleasePool in main() – I’m not allowed to touch

  • 0

I can’t have a “big” NSAutoreleasePool in main() – I’m not allowed to touch it. So what’s about having one pool per object?

struct MacGuiEngine
{
  // members …

  ScopedAutoreleasePool pool;
};

struct MacFontEngine
{
  // members …

  ScopedAutoreleasePool pool;
};

Is this a valid “pattern”?

  • 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-21T03:08:48+00:00Added an answer on May 21, 2026 at 3:08 am

    When you say you can’t touch main(), when do you call UIApplicationMain()? I’m assuming this is iOS, since you don’t need to create an autorelease pool in main() on Mac. Wherever you call UIApplicationMain() is where you want the top-level autorelease pool.

    Remember, an autorelease pool is automatically created for you for each event loop, so you generally don’t need to create one. My initial experiments are that removing it from main() on iPad at least didn’t cause any leaks. You can find out by setting a breakpoint on __NSAutoreleaseNoPool(). The only concern would be methods called prior to the event loop. I believe if the application delegate is generated programmatically, then its -init may be called prior to an event loop. But even making autoreleased objects in app delegate’s +initialize didn’t cause any leaks for me.

    If there are any places you need an autorelease pool (where __NSAutoreleaseNoPool() gets called and you see something like “object autoreleased without pool — just leaking”), then you just need to create a pool in that method:

    - (id)someMethod {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        ....
        id result = ....
    
        [pool drain];
        return result;
    }
    

    But I’m still a little at a loss of how you’re starting your main runloop, but can’t create an autorelease pool.

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

Sidebar

Related Questions

Can somebody point me to a resource that explains how to go about having
Can I order my users in the database, so I don't have to say
Can any one tell, how to get the result of LINQ query contains group
Can I be sure about the order in a Python dictionary? The function op.GetTangent(id)
I have a jquery bug and I've been looking for hours now, I can't
Can you guys help me understand a concept real quick, I'm having trouble understanding
Can't figure out how to do this in a pretty way : I have
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can any one tell me clearly why ? Reading is simple in ArrayList,( we
Can anyone help me as what is going wrong here? Am not able to

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.