NSDate内存泄漏问题
我在 NSDate
发生内存泄漏。请查看下面的代码。
-(void)myMethods:(NSDate *)currentTime{
[NSThread detachNewThreadSelector:@selector(mySecondMethods) toTarget:self withObject:nil];
}
-(void) mySecondMethods{
NSDate * currentDateTime = [NSDate date];------->memory leak here
for (Event * event in array) {
if(![event checkOccur:currentDateTime]){
return;
} else {
[NSThread detachNewThreadSelector:@selector(start) toTarget:event withObject:nil];
}
}
}
I have a memory leak at NSDate
. Please review the code below.
-(void)myMethods:(NSDate *)currentTime{
[NSThread detachNewThreadSelector:@selector(mySecondMethods) toTarget:self withObject:nil];
}
-(void) mySecondMethods{
NSDate * currentDateTime = [NSDate date];------->memory leak here
for (Event * event in array) {
if(![event checkOccur:currentDateTime]){
return;
} else {
[NSThread detachNewThreadSelector:@selector(start) toTarget:event withObject:nil];
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在线程中调用任何方法,则必须使用自动释放池。
If you are calling any method in a thread you have to use Autorelease Pool.