2

我正在尝试在我的项目中执行线程操作。事情进展顺利,但我正在NSAutoreleaseNoPool(): Object 0x66ad9d0 of class NSConcreteMutableData autoreleased with no pool in place - just leaking关注我的 NSLOG。

我的代码是..

NSAutoreleasePool *MyPool = [[NSAutoreleasePool alloc] init];
[NSThread detachNewThreadSelector:@selector(insertSyncRec:) toTarget:self withObject:dict];
[MyPool drain]; // [MyPool release]; too

我的日志消息是:

2011-05-03 17:29:51.262 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd5034d0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.262 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd504190 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.263 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd503930 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.264 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd5066a0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.265 MLead[7240:7e13] *** __NSAutoreleaseNoPool(): Object 0xd4180e0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.266 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd507260 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.266 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd506a50 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.269 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd507af0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.271 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd419a20 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.271 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd4061f0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.267 MLead[7240:7e13] *** __NSAutoreleaseNoPool(): Object 0xd418dc0 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.272 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xa3f5650 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.272 MLead[7240:7e13] *** __NSAutoreleaseNoPool(): Object 0xd4185c0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.272 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd5068c0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.281 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd508f70 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.282 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd504b10 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.272 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd41a470 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.283 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd41ba60 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.284 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd418eb0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.284 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd41bc40 of class NSCFString autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.273 MLead[7240:7e13] *** __NSAutoreleaseNoPool(): Object 0xd506db0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.284 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd41b540 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.285 MLead[7240:8513] *** __NSAutoreleaseNoPool(): Object 0xd5086e0 of class __NSCFData autoreleased with no pool in place - just leaking
2011-05-03 17:29:51.286 MLead[7240:8407] *** __NSAutoreleaseNoPool(): Object 0xd507c30 of class __NSCFData autoreleased with no pool in place - just leaking

等等..

我错过了什么..经过大量谷歌搜索后,我才发现创建一个新池..但没有奏效..

提前致谢..

4

2 回答 2

1

I also had the same problem,instead of attaching the task to a new thread try in the same thread. [self insertSyncRec:dict];

I fixed my problem doing it this

于 2011-10-31T13:22:07.023 回答
1

不应该在线程本身内创建池吗?

于 2011-06-15T05:27:06.767 回答