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

  • Home
  • SEARCH
  • 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 6793661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:07:37+00:00 2026-05-26T18:07:37+00:00

I am developing an application that needs to work on Linux, Windows and Mac

  • 0

I am developing an application that needs to work on Linux, Windows and Mac OS X. To that purpose, I am using C++ with Qt.

For many reasons, on Mac OS X, I need to use CoreFoundation functions (such as CFBundleCopyBundleURL) that creates core objects that need to be released with CFRelease. But doing so generate a lots of these warnings:

*** __NSAutoreleaseNoPool(): Object 0x224f7e0 of class NSURL autoreleased with no pool in place - just leaking

All the code I’ve seen concerning these autorelease pools is written in Objective-C. Does anybody know how to create/use autorelease pools in C or C++?

  • 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-26T18:07:38+00:00Added an answer on May 26, 2026 at 6:07 pm

    id is a C declaration. You can simply add scope based autorelease pools to your cpp program like so:

    autorelease_pool.hpp

    class t_autorelease_pool {
    public:
        t_autorelease_pool();
        ~t_autorelease_pool();
    private:
        id d_pool; // << you may opt to preprocess this out on other platforms.
    private:
        t_autorelease_pool(const t_autorelease_pool&);
        t_autorelease_pool& operator=(const t_autorelease_pool&);
    };
    

    autorelease_pool.mm

    t_autorelease_pool::t_autorelease_pool() : d_pool([NSAutoreleasePool new]) {}
    t_autorelease_pool::~t_autorelease_pool() { [this->d_pool drain]; }
    

    In a cpp program:

    void UpdateUI() {
        t_autorelease_pool pool;
        // your/their autoreleasing code here
    }
    

    An alternative (which can be very easy to use incorrectly) is to use the ObjC runtime directly – which would look like the following C program:

    #include <objc/runtime.h>
    #include <objc/message.h>
    ...
    id pool = objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("new")); 
    /* do stuff */
    objc_msgSend(pool, sel_getUid("drain"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application that needs to use regini (because of legacy reasons)
Hi I am developing an application that needs to work with a complex domain
I am developing a application that needs to store data with many writes and
I am developing an internally-facing application that needs to automatically authenticate users via Windows
I'm developing an iOS application that needs to deploy to iOS 3.1.3. I need
I'm developing an application that needs to interact over FTP. For this communication I
I'm developing an application that needs to perform some processing on the user's Outlook
I am developing an application that needs to inform users (around 1800) on a
I am developing an application that needs to read back the whole frame from
I'm developing a small utility application that needs to detect whether another one has

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.