【发布时间】:2011-11-03 14:18:24
【问题描述】:
我在为 iOS 编译项目时收到类似以下错误的错误列表。
2011-08-25 12:32:44.016 rtsp[55457:6003]
*** __NSAutoreleaseNoPool(): Object 0x64095a0 of class __NSArrayM
autoreleased with no pool in place - just leaking
因为下面的函数而出现
- (void) start {
//Existing code
session = [[RTSPClientSession alloc] initWithURL:
[NSURL URLWithString:
@"rtsp://video3.americafree.tv/AFTVComedyH2641000.sdp"]];
[session setup];
NSLog(@"getSDP: --> %@",[ session getSDP ]);
NSArray *array = [session getSubsessions];
for (int i=0; i < [array count]; i++) {
RTSPSubsession *subsession = [array objectAtIndex:i];
[session setupSubsession:subsession clientPortNum:0 ];
subsession.delegate=self;
[subsession increaseReceiveBufferTo:2000000];
NSLog(@"%@", [subsession getProtocolName]);
NSLog(@"%@", [subsession getCodecName]);
NSLog(@"%@", [subsession getMediumName]);
NSLog(@"%d", [subsession getSDP_VideoHeight]);
NSLog(@"%d", [subsession getServerPortNum]);
}
[session play];
NSLog(@"error: --> %@",[session getLastErrorString]);
[session runEventLoop:rawsdp];
}
当我将和NSAutoreleasePool 添加到我的函数时
- (void) start {
NSAutoReleasePool *pool=[[NSAutoReleasePool alloc] init];
session = [[RTSPClientSession alloc] initWithURL:[NSURL ...
...
[pool drain];
}
错误消失了,但我的函数没有得到任何输出。添加NSAutoreleasePool 是正确的解决方案吗?
【问题讨论】:
标签: ios multithreading memory-leaks xcode4