循环中大量生成的自动释放autorelease对象,可以考虑使用autorelease pool封装
循环中大量生成的自动释放autorelease对象,可以考虑使用autorelease pool封装
代码范例:
- for(UIView *subview in bigView.subviews) {
- // 使用autorelease pool自动释放对象池
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- UIImageView *imageView = (UIImageView *)subview;
- // subview处理代码
- .......
- // 销毁自动释放对象
- [pool drain];
- }
自动释放对象池把每个循环内生成的临时对象使用完后立即释放

浙公网安备 33010602011771号