0
我嘗試在dispatch_async
塊中使用autoreleasepool
,但是it doesn't release the str
。當timerEvent被重複調用時,會導致內存耗盡問題。爲什麼@autoreleasepool不起作用
- (void)viewDidLoad
{
[super viewDidLoad];
[NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(timerEvent) userInfo:nil repeats:YES];
}
-(void)timerEvent
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
@autoreleasepool {
NSString *str =[NSString stringWithFormat:@"%d and %d",px,py];
NSLog(str);
}
});
}
謝謝你的幫忙。
-----解決---------------由於C_X
計時器間隔已設定過小。就我而言,我發現它應該至少爲0.004。現在,它的工作。