关于为什么在调用方法Sample
后此代码会泄漏(过度保留)类的实例的任何想法?[startSampling:action:]
Profiler 在采样完成后显示正保留计数(即sample()
块返回YES
)。ARC显然已启用。
@implementation Sample
- (void)startSampling:(BOOL (^)(Sample *sender))sample action:(void (^)(Sample *sender))action {
__block void (^next)(Sample *sender) = nil;
void (^block)(Sample *sender) = ^(Sample *sender) {
if (sample(sender)) {
action(sender);
} else {
[self performBlock:next afterDelay:self.duration / 100.0];
}
};
next = block;
[self performBlock:block afterDelay:self.duration / 100.0];
}
@end