views:

16

answers:

2

Hi

I have this in my main.m:

printf("make autorelease pool \n");
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, @"UIApplication", @"MyAppDelegate");
[pool release];
return retVal;

And i suddenly started to get this when I run my app on the simulator:

2010-08-27 11:09:35.909 MyApp[6224:207] *** _NSAutoreleaseNoPool(): Object 0x49107c0 of class NSPathStore2 autoreleased with no pool in place - just leaking

Stack: (0xe171f 0x58d64 0x59ebd 0x599ee 0x600c7 0x31d016 0x23198 0x29e94ae 0x29e97c4 0x29ee7c4 0x8fe036c8 0x8fe0d30a 0x8fe0d3d1 0x8fe024a9 0x8fe07950 0x8fe018b1 0x8fe01057)

2010-08-27 11:09:35.911 MyApp[6224:207] * _NSAutoreleaseNoPool(): Object 0x49110c0 of class NSPathStore2 autoreleased with no pool in place - just leaking Stack: (0xe171f 0x58d64 0x5cd69 0x60335 0x601f1 0x31d016 0x23198 0x29e94ae 0x29e97c4 0x29ee7c4 0x8fe036c8 0x8fe0d30a 0x8fe0d3d1 0x8fe024a9 0x8fe07950 0x8fe018b1 0x8fe01057)

2010-08-27 11:09:35.912 MyApp[6224:207] * _NSAutoreleaseNoPool(): Object 0x4911ce0 of class NSPathStore2 autoreleased with no pool in place - just leaking Stack: (0xe171f 0x58d64 0x6902e 0x445545 0x23198 0x29e94ae 0x29e97c4 0x29ee7c4 0x8fe036c8 0x8fe0d30a 0x8fe0d3d1 0x8fe024a9 0x8fe07950 0x8fe018b1 0x8fe01057) make autorelease pool

Does anyone have any idea what's causing this? Any help much appreciated!

A: 

That's probably from a thread where no autorelease pool is in place. You have to set up an own autorelease pool for each thread. Even if you just use an NSOperation or [NSObject performSelectorInBackground:withObject:] you have to put an autorelease pool in place.

Side note: NSAutoreleasePool should be released using its drain method. This method calls release and is equivalent in non-garbage-collected environments, like iOS 4. It's just good style to always use drain. When using garbage collection, it triggers a non-exhaustive collection.

Nikolai Ruhe
Hello NikolaiThanks! I think I found what was causing it. I have a method to load my textures and its signature looked like this+(void)loadApparently, this gets called at app startup even if you don't import the file containing the method anywhere. Changing the signature to +(void)loadTextureprevents it from being called prematurely, thereby fixing the "bug"!
Paul the n-th
+1  A: 

I think I found what was causing it. I have a method to load my textures and its signature looked like this +(void)load Apparently, this gets called at app startup even if you don't import the file containing the method anywhere. Changing the signature to +(void)loadTexture prevents it from being called prematurely, thereby fixing the "bug"!

Sorry for answering my own question. I hope this saves someone's time.

Paul the n-th
Good detective work. Here's the reason for the behavior: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/doc/uid/20000050-load
Nikolai Ruhe