Reputation: 1239
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!
Upvotes: 2
Views: 238
Reputation: 1239
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.
Upvotes: 2
Reputation: 81868
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.
Upvotes: 0