4

[It's not DLog, it was a separate thread. See edits/comments below]

XCode 4.3 I'm using the common preprocessor macro for debug logging:

#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); 
#else
#   define DLog(...)
#endif

Compiles/works fine under iOS 5.0, but when I run it under iOS 4.3 I get a ton of "autoreleased with no pool in place - just leaking" errors whenever DLog is executed. Tried rebooting, no help.

Am I haunted, or is there a solution? TIA.

[edit 1]

Forgot to mention it's an ARC project. The only autorelease pool is the default in main.m:

@autoreleasepool {
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    return retVal;
}

There's nothing special about any of my DLog use, in fact the errors trigger upon app start when I simply put

DLog(@"didFinishLaunchingWithOptions");

[edit 2]

Sorry, it's not DLog causing the issue. Here's the first line that will cause it for me:

BOOL customDates = [[defaults objectForKey:@"custom_dates"] boolValue];

Console reports:

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

I'm still confused by all these leak messages because I thought we didn't need to worry about autorelease with ARC. So what is its problem?

Tim K
  • 333
  • 3
  • 9
  • That would indicate the code is running with no autoreleasepool in place. Any chance you can show a code block where you use `DLog` that would match that description? Also, do you use `@autoreleasepool` blocks anywhere in your code? – Itai Ferber Mar 03 '12 at 22:23
  • 1
    Do you use threads anywhere in your project? Or possibly a `__attribute__((constructor))` function? – Richard J. Ross III Mar 03 '12 at 22:50
  • No threads. Fairly simple project. This has seemingly come out of nowhere. I am completing the updating of a non-ARC iOS 4 iPhone app to ARC and iOS 5 (though no iOS 5-specific code is being used). – Tim K Mar 03 '12 at 23:02
  • Does the message also say "break on objc_autoreleaseNoPool() to debug"? – rob mayoff Mar 03 '12 at 23:09
  • Not Dlog but still getting the problem, see edits to original post. Sorry. – Tim K Mar 04 '12 at 02:35
  • Gah! I forgot that I *do* have a thread: MBProgressHUD works by executing a thread in the background while updating a progress HUD. So if I wrap the entire code that executes with @autorelease the issue goes away. Why does this only occur in iOS 4.3? – Tim K Mar 04 '12 at 02:54
  • you may want to refer to this question: http://stackoverflow.com/questions/9770213/arc-memory-leaks – BabyPanda Mar 02 '14 at 07:12

0 Answers0