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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:54:46+00:00 2026-06-02T06:54:46+00:00

Here’s a simple class: #import One.h #import Two.h @implementation DataFileRegistrar static NSMutableDictionary *elementToClassMapping; +

  • 0

Here’s a simple class:

#import "One.h"
#import "Two.h"

@implementation DataFileRegistrar

static NSMutableDictionary *elementToClassMapping;

+ (void)load
{
    [self registerClass:[One class] forElement:@"one"];
    [self registerClass:[Two class] forElement:@"two"];
}

+ (void)registerClass:(Class)class forElement:(NSString *)element
{
    if (!elementToClassMapping) {
        elementToClassMapping = [NSMutableDictionary dictionaryWithObject:class forKey:element];
    } else {
        [elementToClassMapping setValue:class forKey:element];
    }
}

+ (id)classForElement:(NSString *)element
{
    return [elementToClassMapping valueForKey:element];
}

@end

The problem is this compiler message:

objc[7172]: Object 0x6840720 of class __NSCFDictionary autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

Any ideas what’s going on?

Basically, I want to have a simple class with a couple of class methods and one static dictionary. It would be always used without instantiation. I want to use it for a couple of things right after the app starts and then I want to release its memory. I thought ARC can take care of this.

  • 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-06-02T06:54:47+00:00Added an answer on June 2, 2026 at 6:54 am

    Your class’ +load is calling methods which calls autorelease.

    Your class is loaded before main.

    You can explicitly create an autorelease pool in +load:

    + (void)load
    {
        @autoreleasepool {
            [self registerClass:[One class] forElement:@"one"];
            [self registerClass:[Two class] forElement:@"two"];
        }
    }
    

    However, it’s often better to guarantee the order of your program’s initialization and load explicitly before creating any threads in main:

    int main(int argc, const char * argv[]) {
      @autoreleasepool {
          [DataFileRegistrar initializeStaticStuff];
          ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
Here's my code. It tries to load Leaflet library. When I turn crossDomain option
Here is a app contorller directory from Rails project doing a self study for
Here is a simple demonstration of what I'm talking about js in head tag:
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here a simple question : What do you think of code which use try
Here's what I'm trying to do... It's quite simple and obviously there must be
Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>

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.