小编pmo*_*man的帖子

UILabel(CALayer)正在使用大量虚拟内存

Xcode and Instruments我看到UILabel (CALayer)使用大量的虚拟内存(匿名VM).我看到每个大约235 KB的虚拟内存UILabel.

我认为这可能是iOS 7.1或7.1.1的新问题.

这是预期的吗?

我创建了一个简单的程序,创建500 UILabelsInstruments显示115MB的内存使用.在大约1500个标签处,应用程序由OS终止.

for (int i = 0; i < 500; i++)
{
    index = (int)[self.items count];
    index++;

    frame = CGRectMake(10.0, 20, 300.0, 50.0);

    UILabel *newLabel = [[UILabel alloc] initWithFrame:frame];
    newLabel.text = [NSString stringWithFormat:@"This is text for label: %d", index];
    newLabel.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:newLabel];

    [self.items setObject:newLabel forKey:[NSNumber numberWithInteger:index]];
}
Run Code Online (Sandbox Code Playgroud)

思考?

xcode anonymous virtual-machine instruments ios

9
推荐指数
2
解决办法
3508
查看次数

标签 统计

anonymous ×1

instruments ×1

ios ×1

virtual-machine ×1

xcode ×1