0

我在 iphone 2.0 中使用这行代码它工作正常

pool=[[NSAutoreleasePool alloc]init];

[pool release];

当我在 iphone 3.0 中运行这行代码时,它会在日志屏幕中给出一些泄漏消息。该消息是

2009-10-13 03:26:31.841 Spectrum[3946:4c2b] *** _NSAutoreleaseNoPool(): Object 0xd819d0 of class NSCFString autoreleased with no pool in place - just leaking
Stack: (0x305a2e6f 0x30504682 0x52c14d 0x536f67 0x3058deff 0xb049 0xa554 0x3050a79d 0x3050a338 0x97181155 0x97181012)

谁能帮我?

提前致谢....

4

3 回答 3

1

Your pool allocation and release code looks fine. The error message, nevertheless, indicates something was allocated with autorelease outside the scope of an autorelease pool. This often happens in when you use a secondary thread, when using some specialty load methods, and when initializing globals.

Once you isolate the leaking bit of code, you could try wrapping it by another set of NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; and [pool release];.

于 2009-10-13T08:26:18.503 回答
1

That message occurs when an object is sent the autorelease message outside of an autorelease scope. Place a breakpoint on _NSAutoreleaseNoPool and check the stack to see where the pool needs to be added.

于 2009-10-13T08:27:37.513 回答
0

Look for any place in your code where you make autoreleased objects, while inside another thread than your main run loop.

于 2009-10-13T08:28:56.530 回答