6中泄漏CGContextDrawPDFPage

6中泄漏CGContextDrawPDFPage

本文介绍了在iOS 6中泄漏CGContextDrawPDFPage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在研究几个基本上是PDF阅读器的应用程序。从iOS 6开始,应用程序因内存不足而崩溃。
我们的应用程序使用,但问题与此无关。到目前为止,我们发现:

1.泄漏来自 CGContextDrawPDFPage

2.它不存在(或不存在)如此突出)在iOS< 6

3.没有压缩或压缩的PDFS上不会发生泄漏


I'm working on several apps which are basically a PDF readers. Since iOS 6, apps started crashing because of being out of memory.Our apps utilize PDF Reader, but a problem is not related to it. So far we found out:
1. leaking comes from CGContextDrawPDFPage
2. it is not there (or not so prominent) in iOS <6
3. leak does not occur on PDFS with no or small compression

具体说明:打开后带有一些压缩的PDF,使用了一些内存。关闭PDF时,会释放部分内存。然而,并非全部。您可以轻松获取内存警告,然后只需打开&多次关闭PDF。

我也试过,虽然它有优势(在PDF阅读器上,它的成本要高得多,同样的泄漏也在那里。

To be specific: after opening a PDF with some compression, some memory is used. When PDF is closed, part of that memory is released. However, not all of it. You can easily get memory warning and then crash the app just by opening & closing PDF several times.
I've tried also PSPDF and although, it has advantages (speed) over PDF Reader, it's much more expensive and the same leaking is in there.

我为和。 (你只需要为项目添加一些PDF)

I have created very simple test project for PDF Reader and PSPDF Kit. (you just need to add some PDF to project)

我有什么办法可以修复iOS 6中的泄漏,或者我做错了什么,实际上没有泄漏?我目前的方法是等待正式修复。

我知道这个问题在这里有重要讨论,但我相信我的情况有点不同。 (使用ARC和经过测试的库,在模拟器和设备上可见泄漏)

Is there anything I can do to fix leaking in iOS 6 or am I doing something wrong and there is actually no leaking? My current approach is to wait for official fix.
I know the issue was discussed heavily here, but I believe my situation is a little bit different. (using ARC and tested libraries, leaking visible in simulator and on devices)

谢谢。

推荐答案

经过大量的尝试,我发现只有两个解决方案。但是,它们都不是完美的。

After a lot of trying, I've found out only two solutions. None of them is perfect, though.

1)使用Apple的

- 它在iOS中没有泄漏< 6.0

- 它在iOS 6.0中没有泄露。

1) Use Apple's QuickLook framework
- It is not leaking in iOS <6.0
- It is not leaking in iOS 6.0.

QuickLook使用XPC在另一个进程中运行。但是,这也意味着几乎没有定制。 (请参阅问题以及链接的博客文章)

QuickLook runs in another process using XPC. However, that also means there is practically no customization. (see this question with a linked blog post)

2)使用库

似乎没有涉及 CGContextDrawPDFPage 或者只是一些聪明的优化,但FastPdfKit没有泄漏。缺点是两个 - 库是商业的,即使你购买了许可证,它的渲染引擎也不会显示给你。
您可以使用包含所有功能的免费版本,但有一个闪屏。

2) Use FastPdfKit library
There seems to be no CGContextDrawPDFPage involved or maybe just some clever optimizations, but FastPdfKit is not leaking. Disadvantages are two - library is commercial and its rendering engine won't be shown to you even after you buy a license.You can use a free version with all the features, but there is a splash screen.

因为我们正处于时间压力之下而且负担不起既不等待官方错误修正,也不保留我们目前的功能,我们选择了FastPdfKit。

As we're under a time pressure and can't afford neither to wait for official bugfix, nor leave our current features out, we've chosen FastPdfKit.

我不认为这是一个明确的答案。图书馆适合我们的需求,可能不适合您。此外,它是一种商业产品。如果有更直接的解决方案,我很乐意接受它。

I wouldn't consider this to be a definite answer. The library suits our needs, might not yours. Also, it is a commercial product. If there is more straightforward solution, I'll gladly accept it.

这篇关于在iOS 6中泄漏CGContextDrawPDFPage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 00:47