【问题标题】:renderInContext / Memory problemrenderInContext / 内存问题
【发布时间】:2011-03-31 09:05:01
【问题描述】:

我有问题。当我在 iPad 中使用“renderInContext”时,使用的内存永远不会释放并累积,直到应用程序以“内存警告”级别=1 和级别=2 关闭

我的代码:

CGRect mediaBox = CGRectMake(0, 0, 16.54 * 72.0, 24.02 * 72.0);
            CGContextRef ctx = CGPDFContextCreateWithURL((CFURLRef)[NSURL fileURLWithPath:posterPath isDirectory:NO], &mediaBox, NULL);
            CGPDFContextBeginPage(ctx, NULL);
            CGContextScaleCTM(ctx, 0.516, -0.516);
            CGContextTranslateCTM(ctx, 0, -mediaBox.size.height - 1500);
            [[self returnBigView].layer renderInContext:ctx];
            CGPDFContextEndPage(ctx);
            CGPDFContextClose(ctx);
            CGContextRelease(ctx);

我尝试了几种方法,但没有可用内存。有什么想法吗?

** 对不起我的英语不好

【问题讨论】:

    标签: memory memory-management


    【解决方案1】:

    我也有同样的问题,在一个循环中 - 将图层内容设置为 nil 对我有用:

    Releasing renderInContext result within a loop

    【讨论】:

      【解决方案2】:

      我有同样的问题。经过长时间的调查,似乎没有释放内存,因为代码没有在主线程上运行。所以当你不在主线程上工作时不要执行renderInContext!

      【讨论】:

        猜你喜欢
        • 2012-04-25
        • 1970-01-01
        • 1970-01-01
        • 2013-11-07
        • 2011-02-16
        • 2017-12-08
        • 1970-01-01
        • 1970-01-01
        • 2010-09-22
        相关资源
        最近更新 更多