小编Vin*_*pra的帖子

NSLog 对应用程序性能有什么影响吗?

嗨,我在我的应用程序中进行了大量计算,因为我的NSLog声明至少是 11 MB 的大应用程序的 2000 倍。我正在考虑从我的应用程序中删除它以提高性能。我想以正确的方式??

performance nslog ios

4
推荐指数
1
解决办法
1449
查看次数

由于CTFontRef导致记忆泄漏

我使用下面的代码生成PDF但是导致内存泄漏可以有人帮忙吗?代码如下.

- (void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect {


    NSMutableAttributedString *string = [[[NSMutableAttributedString alloc]
                                         initWithString:textToDraw] autorelease];

    // make a few words bold

    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica-Bold"), 8.0, NULL);

    [string addAttribute:(id)kCTFontAttributeName
                   value:(id)helveticaBold
                   range:NSMakeRange(0, [string length])];

    // add some color.
    if (_flag == 1) {

        [string addAttribute:(id)kCTForegroundColorAttributeName
                       value:(id)[UIColor whiteColor].CGColor
                       range:NSMakeRange(0, [string length])];


    } else {

        [string addAttribute:(id)kCTForegroundColorAttributeName
                       value:(id)[UIColor blackColor].CGColor
                       range:NSMakeRange(0, [string length])];
    }

    // layout master
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)string);

    CGMutablePathRef framePath = CGPathCreateMutable();
    CGPathAddRect(framePath, NULL, frameRect);

    // Get the frame that will do the rendering. …
Run Code Online (Sandbox Code Playgroud)

memory-leaks ios ctfontref

2
推荐指数
1
解决办法
1216
查看次数

标签 统计

ios ×2

ctfontref ×1

memory-leaks ×1

nslog ×1

performance ×1