Jas*_*son 3 iphone memory-management objective-c nsautoreleasepool ios
在我的iPhone应用程序中,在应用程序的最开始,我在控制台中收到三个奇怪的警告,然后才会调用任何代码:
*** __NSAutoreleaseNoPool(): Object 0x84be00 of class NSCFString autoreleased with no pool in place - just leaking
*** __NSAutoreleaseNoPool(): Object 0x84b000 of class NSCFString autoreleased with no pool in place - just leaking
*** __NSAutoreleaseNoPool(): Object 0x849c00 of class NSCFString autoreleased with no pool in place - just leaking
Run Code Online (Sandbox Code Playgroud)
我在许多地方使用MBProgressHUD来显示进度指示器,这是该问题的一些其他讨论所指出的,因为它在显示进度指示器时抛出新线程.但最奇怪的是,这些似乎甚至在我的main()函数开始之前抛出:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
当我在第一个代码中放入一个断点时NSAutoreleasePool,在该行甚至运行之前我得到了这个警告.什么可能导致错误,据说,在此之前我没有运行任何我自己的代码?
在main()触发此问题之前,您可能有一个正在运行的构造函数.您链接哪些库和/或您正在使用任何__attribute__指令?
HERP.
意识到明显的东西.由于物体泄漏,它们仍然存在.设置断点main(),然后在GDB提示符下键入po 0x84be00(仅替换0x84be00为泄漏的其中一个字符串的地址).
那将向您展示该字符串的内容,并为您提供一个非常好的线索,了解原因是什么.
DERP.
设置断点__NSAutoreleaseNoPool并查看回溯显示的内容.
我今天明显失败了(唯一明显的是因为我已经走了这条路18,273.14万次).
| 归档时间: |
|
| 查看次数: |
3937 次 |
| 最近记录: |