泄漏NSAutoreleasePool [英] Leaking NSAutoreleasePool

查看:71
本文介绍了泄漏NSAutoreleasePool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,还剩下1个漏洞. 泄漏的对象是NSAutoreleasePool,大小为32个字节. 在stacktrace中,仅调用基础方法. 我不知道如何解决这个问题.

I'm working on an app and have 1 leak left. The leaked object is NSAutoreleasePool, size is 32 bytes. In the stacktrace only foundation methods are called. I have no clue how to resolve this.

在模拟器中没有泄漏报告,在设备上只有此泄漏.

In simulator no leaks reported, on the device only this leak.

有什么主意吗?

自动释放池是我自己定义的一个.

The autoreleasepool is one I define myself.

在我的视图控制器中,我致电:

In my viewcontroller I call:

[self performSelectorInBackground:@selector(getDetailInfo:) withObject:self.infoID];

这是getDetailInfo:

This is getDetailInfo:

- (void)getDetailInfo:(NSString *)theID {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    DetailInfo *info = [[DataProvider sharedInstance] getDetailInfo:theID]; //the return object is autoreleased.
    [self performSelectorOnMainThread:@selector(updateViewWithDetailInfo:) withObject:info waitUntilDone:NO];

    [pool release];
}

一些其他信息:

为了进行测试,我将使用performSelectorInBackground调用的所有方法都更改为在主线程上运行,并删除了这些自动释放池.

For testing I changed all my methods which were called using performSelectorInBackground to run on the main thread and removed those autoreleasepools.

我仍然在NSAutoreleasePool上收到泄漏.今天,我了解到您可以在工具的堆栈跟踪中显示库名称". :-)我在下面复制了它,您可以在第6行和第7行看到MapKit.

I still received the leak on the NSAutoreleasePool. Today I learned that you can show the "Library name" in the stacktrace in instruments. :-) I copied it below and you can see the MapKit on line 6 and 7.

0 libSystem.B.dylib calloc
1 libobjc.A.dylib _internal_class_createInstanceFromZone
2 libobjc.A.dylib class_createInstance
3 CoreFoundation +[NSObject(NSObject) allocWithZone:]
4 Foundation +[NSAutoreleasePool allocWithZone:]
5 CoreFoundation +[NSObject(NSObject) alloc]
6 MapKit TileCachePrivate::runCacheThread()
7 MapKit _runCacheThread(void*)
8 libSystem.B.dylib _pthread_start
9 libSystem.B.dylib thread_assign_default

这是地图视图的代码:

    MKMapView *omgeving = [[MKMapView alloc] initWithFrame:CGRectMake(11, 22, 298, 297)];
    omgeving.delegate = nil;
    [self addSubview:omgeving];
    [omgeving release];     

如果我注释掉MapView代码,则不会泄漏.如果我把它留在里面,就会漏水.

If I comment out the MapView code, no leak. If I leave it in, I get the Leak.

Leaked Object       #   Address     Size    Responsible Library Responsible Frame
NSAutoreleasePool       0x6a52e50   32      Foundation          +[NSAutoreleasePool allocWithZone:]

感谢到目前为止的所有评论. 有什么建议吗?

Thanks for all the comments so far. Any suggestions?

推荐答案

已知问题: https://devforums.apple.com/message/282497#282497

感谢您的思考.

这篇关于泄漏NSAutoreleasePool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆