iOS 8.1中CGContextDrawPDFPage中的内存泄漏?

 昔日重来r_510 发布于 2022-12-12 18:40

在iOS 8.1下,使用CGContextDrawPDFPage将PDF页面呈现到图形上下文中时出现内存泄漏。在模拟器中并没有发生这种情况,但是每次(在iPad Air上),都会发生数百次272字节的malloc内存泄漏。如果我注释掉CGContextDrawPDFPage,泄漏将消失。

还有其他人会得到类似的行为吗?

CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef)data);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(dataProvider);


CGPDFPageRef page;

// Grab the PDF page
page = CGPDFDocumentGetPage(pdf, pageNo + 1);

UIGraphicsBeginImageContext(aRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextTranslateCTM(context, 0, aRect.size.height);
CGContextScaleCTM(context, 1, -1);

CGContextDrawPDFPage(context, page); // <-  LEAKING?!?!?

// Would create the new UIImage from the context
//image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

CGPDFDocumentRelease(pdf);
CGDataProviderRelease(dataProvider);

这是堆栈跟踪(反向):

分配

38.58 MB 36.7%148743 std :: __ 1 ::列表> ::列表(std :: __ 1 ::列表> const&)

19.61 MB 18.6%75610 std :: __ 1 :: vector CG :: Path :: Subpath CG :: Allocator

19.61 MB 18.6%75610 void std :: __ 1 :: vector> :: __ push_back_slow_path(CG :: Path :: Subpath &&)

19.61 MB 18.6%75610 CG :: Path :: Sequence :: move_to_point(CGPoint const&,CGAffineTransform const *)

19.61 MB 18.6%75610 CGPathMoveToPoint

19.59 MB 18.6%75506 TTrueTypeQuadOutlineContext :: AddPoint(bool,int,int)

19.59 MB 18.6%75506 TTrueTypeFontHandler :: RenderGlyph(unsigned short,TTrueTypeQuadOutlineContext&,unsigned int)const

19.59 MB 18.6%75506 TTrueTypeFontHandler :: GetOutlinePath(unsigned short,TGlyphOutlineBatch const&)const

19.59 MB 18.6%75506 FPFontCopyGlyphPath

19.59 MB 18.6%75506 CGFontCreateGlyphPath

19.59 MB 18.6%75506 CGFontCreateGlyphBitmap

19.59 MB 18.6%75506 CGGlyphBuilder :: create_missing_bitmaps(CGGlyphIdentifier const *,unsigned long,CGGlyphBitmap const **)

19.59 MB 18.6%75506 render_glyphs

19.59 MB 18.6%75506 draw_glyph_bitmaps

19.59 MB 18.6%75506 ripc_DrawGlyphs

19.59 MB 18.6%75506 draw_glyphs

19.57 MB 18.6%75434 draw_glyphs

19.55 MB 18.6%75359 simple_draw

19.55 MB 18.6%75359 CGPDFTextLayoutDrawGlyphs

19.55 MB 18.6%75348 op_TJ

19.55 MB 18.6%75348 pdf_scanner_handle_xname

19.55 MB 18.6%75348 CGPDFScannerScan

19.55 MB 18.6%75348 CGPDFDrawingContextDrawPage

19.55 MB 18.6%75348 pdf_page_draw_in_context

19.55 MB 18.6%75348 CGContextDrawPDFPage

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有