我试图捕捉场景,如果没有autorelease池。
这是我的测试应用程序。AutoreleasePool没有捕捉断点,没有警告,仪器中没有报告泄漏
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self performSelectorInBackground:@selector(bgOperation:) withObject:nil];
}
- (void)bgOperation:(id)obj
{
NSString *string [[[NSString alloc] init] autorelease];
}
我试着设置断点objc_autoreleaseNoPool。
我试着用仪器/泄漏进行分析。
OSX 10.7.5 XCode 4.3.3 Targeting 10.6,AutomaticRefCounting = NO,GarbageCollection = Unsupported。
我知道NSApplication包括它自己的autorelease池。但我的理解是每个调用执行SelectorInBackground:需要它自己的autorelease池。从建议
更新:
我想这个..
在main.m文件,没有运气。
int main(int argc, char *argv[])
{
NSString *junk = [[[NSString alloc]init]autorelease];
return NSApplicationMain(argc, (const char **)argv);
}
而且这个..
在我的appDelegate,也没有结果。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[NSThread detachNewThreadSelector:@selector(bgOperation:)
toTarget:self
withObject:nil];
}
而且这个..
随着我的main.m并行线程
void *doJunk(void *ptr){
NSString *junk = [[[NSString alloc]initWithString:@"string with no pool"]autorelease];
NSLog(@"%@", junk);
pthread_exit(NULL);
}
int main(int argc, char *argv[])
{
pthread_t thread;
pthread_create(&thread, NULL, doJunk, NULL);
return NSApplicationMain(argc, (const char **)argv);
}
据我所知,由于操作系统级别或许没有泄漏(还没有证实),但是当我目标10.6我在日志中看到许多“无池”消息。如果它只是由于操作系统级别而泄漏,那么我需要一种方法来在10.7中捕获这些场景,而我的目标是10.6而使用10.7 SDK。
你在寻找日志中的“泄漏”信息吗? –
当我运行应用程序并在10.6中观看控制台时,我只能看到它们。 – estobbart