PDA

View Full Version : "... of class NSCFData autoreleased with no pool in place - just leaking"




Sean Kim
Jun 23, 2011, 05:57 AM
there is no error or warning during compile.
but I get error messages while running.

"... of class NSCFData autoreleased with no pool in place - just leaking"

I wrote the code exactly same as the tutorial
http://www.otierney.net/objective-c.html#dealloc

I know there is memory management solution called autorelease.
but my code doesn't have any autorelease object

thanks

system info:
i686-apple-darwin10-gcc-4.2.1
mac osx 10.6.7



jiminaus
Jun 23, 2011, 06:29 AM
Is your main like this?


int main(int argc, const char* argv[]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

// Actual program here

[pool drain];
return 0;
}

robbieduncan
Jun 23, 2011, 06:56 AM
I know there is memory management solution called autorelease.
but my code doesn't have any autorelease object


Just because you don't autorelease any object does not mean that there are no autoreleased object. Any of the convenience constructors will return an autoreleased object. In fact pretty much any method in the Foundation and Cocoa APIs that returns an object that is not a new/alloc/init/copy method will return an autoreleased object.

So basically you should always have an autorelease pool for every single thread (this may not be true if you are running with GC though).