当前位置:编程学习 > wap >>

关于NSThread 内存管理疑问

今天看了个关于多线程的demo

NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(downloadImage:) object:kURL];
    [thread start];

但是代码中没有执行[thread release]

在NSThread手册中找到
For nongarbage-collected applications, the method selector is responsible for setting up an autorelease
pool for the newly detached thread and freeing that pool before it exits. 

难道在downloadImage中加入autorelease pool就可以了? 内存管理 多线程 --------------------编程问答-------------------- 自己加个自动释放池pool,然后release这个pool,ios5之后支持@autoreleasepool{}的写法 --------------------编程问答--------------------


看看项目是不是ARC的。 --------------------编程问答-------------------- NSThread  内部调用的函数,需要使用Autorelease进行内容控制  2楼正解
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,