在mainQueue中设置buttons
的背景颜色时,我可以看到iOS设备的内存使用量每次点击几百千字节。这是我正在使用的代码:
for(int i=0; i<99;i++){
int x=arc4random_uniform(8);
int y=arc4random_uniform(8);
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
if(i%2==0)
[buttons[x][y] setBackgroundColor:[UIColor grayColor]];
else
[buttons[x][y] setBackgroundColor:[UIColor redColor]];
}];
队列执行得很好,但之后似乎没有释放buttons
。我尝试使用没有做任何事情的ARC,可能它并没有把它识别为泄漏。如果我删除使颜色交替的代码(每次只设置相同的颜色),则内存使用量不会增加。
我没有在队列中放置任何单个语句,也没有占用内存,因此我确信它是某个地方的buttons
僵尸。 但是,我不知道如何从那里找到/清除它们。
非常感谢与ARC合作的解决方案。
编辑:如果我在不使用mainQueue的情况下设置backgroundColor,则不会增加内存使用量。
编辑2:这就是乐器的外观。我无法看到任何特定的内存,一些值似乎与我点击的频率呈线性关系。请告诉我是否有其他我可以点击以获取更多详细信息
答案 0 :(得分:1)
就像@Rob猜测的那样,&#34;回溯记录&#34;已启用。
取自Memory leak with "libBacktraceRecording.dylib" in React Native ios application的答案,您必须删除&#34;编辑方案中的勾号&#34;弹出