Ios sizeWithFont:constrainedToSize:lineBreakMode中的内存泄漏:

Ios sizeWithFont:constrainedToSize:lineBreakMode中的内存泄漏:,ios,objective-c,memory-leaks,instruments,Ios,Objective C,Memory Leaks,Instruments,我在尝试创建CGSize以设置UILabel的正确高度时遇到泄漏。在设置Rowatindexpath的高度时,我也收到了相同的泄漏 这是正在泄漏的代码段: CGSize size = [news.news sizeWithFont:[UIFont fontWithName:@"HelveticaNeue" size:12] constrainedToSize:CGSizeMake(230.0f, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrappi

我在尝试创建CGSize以设置UILabel的正确高度时遇到泄漏。在设置Rowatindexpath的高度时,我也收到了相同的泄漏

这是正在泄漏的代码段:

CGSize size = [news.news sizeWithFont:[UIFont fontWithName:@"HelveticaNeue" size:12] constrainedToSize:CGSizeMake(230.0f, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];

                UILabel *newsLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 50, 230, size.height)];
                newsLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:12];
                newsLabel.textAlignment = NSTextAlignmentLeft;
                newsLabel.text = news.news;
                newsLabel.numberOfLines = 0;
                newsLabel.lineBreakMode = NSLineBreakByWordWrapping;
                newsLabel.textColor = COLOR_DARK_GRAY;
                newsLabel.highlightedTextColor = COLOR_WHITE;
                newsLabel.backgroundColor = COLOR_CLEAR;
                [cell.contentView addSubview:newsLabel];
                [newsLabel release];
以下是泄漏仪表中列出的泄漏:

泄漏对象:icu::UcharCharacteristor 负责图书馆:WebCore 负责帧:WebCore::LineBreakIteratorPool::take(WTF::AtomicString常量&)

还有一个指向同一条管线的不同泄漏:

泄漏对象:icu::UcharCharacteristor 负责图书馆:WebCore 负责帧:WebCore::acquireLineBreakIterator(无符号短常量*,int,WTF::AtomicString常量&)


如果还有什么我可以提供的,我很乐意这样做。我已经通过评论上面的那一行(CGSize的创建)确认了泄漏的是这一行。在模拟器和设备上都发生。

除非您有权访问
WebCore
代码,否则无需执行任何操作。我觉得你的代码很好。苹果的库中有很多小漏洞,你有时只需要接受这些漏洞就不会消失。

在你的声明中
newsLabel.font=[UIFont fontWithName:@“HelveticaNeue”大小:12]
创建一个要自动删除的
UIFont
对象。但是,如果您的代码在没有使用
@autoreleasepool{}
显式设置自动释放池的线程中运行,该对象将永远不会被释放(因为不存在自动释放池),并且将泄漏。

因此,如果您的代码确实在单独的线程中运行,请检查您是否设置了自动释放池。

在这种情况下,这不是问题所在。OP的泄漏不是
UIFont
对象。