Ami*_*k12 8 debugging cocoa multithreading objective-c++
我的应用程序结构如下,核心部分是用C++编写的,并且大量使用线程,我在Objective C上开发UI,如果我不执行该线程它工作正常,但我无法禁用,停止线程,UI在我可以看到的日志中随机崩溃,跟随消息
__NSAutoreleaseNoPool(): Object 0x350270 of class NSCFString autoreleased with no pool in place - just leaking
Run Code Online (Sandbox Code Playgroud)
类似的消息来了一次,通过谷歌搜索来了解,我需要设置NSAutoReleasePool来摆脱它,但如何可能将它与C++代码集成.
编辑:核心库将从UI激活,因此我想,可以肯定地说,UI在主线程中运行,Lib正在创建/终止线程而不通知UI,在这种情况下,我可以在UI中调用AutoReleasePool
谁能指导我?
有关Cocoa多线程的知识,请参阅这些文档:http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html
像你一样设计你的应用程序是可以的,但是应该记住两件事:
像这样:
- (void)backgroundThreadStart
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// do stuff
[pool release];
}
Run Code Online (Sandbox Code Playgroud)
这将修复您的控制台错误,但您可能还有其他问题导致您看到的实际崩溃.
归档时间: |
|
查看次数: |
6865 次 |
最近记录: |