autoreleased with no pool in place - NO new thread is started

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

Why would the following code section print the leak error above?

+ (BOOL)getSkipFlag

    NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
    if ( ![defs objectForKey:_BOOK_ID] )
        [defs setObject:@"yyyy" forKey:_BOOK_ID];

        [defs synchronize];

    if ( ![[defs objectForKey:_BOOK_ID] isEqualToString:@"xxxx"] )
        return NO;

    return skipFlag;


if ( ![ClassXYZ getSkipFlag] )

I don't use a new thread so I should not have a new autorelease pool set up.

Note: NSString *temp = [[NSBundle mainBundle] pathForResource:_CONFIG_PLIST ofType:@"plist"]; - would print the same error I am using iOS 5.1

Thanks for any insight.

UPDATE: ClassXYZ.m ... static BOOL skipFlag = NO;

setter: + (void)setSkipFlag:(BOOL)boolValue { skipFlag = boolValue; }

usage: [ClassXYZ setSkipFlag:YES];

used in static void convert_uri_to_file_name(struct mg_connection *conn, const char *uri, char *buf, size_t buf_len)

Omar you had a good point about where it is used. It turns out if I ClassXYZ's own instance methods for example, it works without errors.


just out of curiosity, if you put the function call inside an @autorelease that log should go away

Generally, The autorelease pool for main thread would be created at the first line of main function. Anything that runs before main function would see that the autorelease pool is absent.

+load function is one reason that would cause the leaks, because it runs before main function. If that's the case, just consider using +initialize instead.

Need Your Help

Audible popping when pausing some HTML5 <audio>

javascript jquery html5 audio

Why does the audio on certain files 'pop' or 'click' when the hoverstate is left, but not on others? Popping can be observed here (JSFiddle). You may have to hover and then unhover a few times to h...