bal*_*ure 5 memory-management allocation core-graphics ios heapshot
昨天,这是在提一个更广泛的问题。我一直在使用堆快照来查明问题,但是它们都是我不熟悉的调用者。我自己编写的方法没有出现,但是CoreGraphics似乎正在疯狂地吞噬内存。
我本周准备提交我的应用程序,但遇到了一个大问题。我一直在做大量的质量检查和泄漏检测,并使用堆放/分配分析完成了该过程。不幸的是,这没有按计划进行。该程序本身并不是在“泄漏”,而是毫无疑问地在攀升。
解释该程序的最佳方法是数学抽认卡(第一个应用程序,学习技巧,我想使其变得简单)。有5个按钮,2个图像视图和2个UILabel。我正在把头撞到墙上,想知道我的设计是否有问题(可能是简短的答案),但我更担心内存的蔓延,这几乎肯定会使我无法进入应用商店。
因此,过程如下:视图显示“主页”按钮(用于返回主菜单),“复选框”(用于标记问题供以后使用),UILabel中的数学问题以及“获取答案”按钮。当您按下“获取答案”时,“答案”显示在第二个UILabel中,另外两个按钮(“对”和“错”)出现,“获取答案”按钮的标题变为“获取问题”。按“获取问题”将我们重新设置为一个新问题。
我一直在使用heapshot来查找占用了多少内存,并且我发现每次进行一次迭代时,我都会损失10-15KB(按“获取答案”,然后按“向右”或“ “错误”)。最严重的罪犯是被称为“ CGGlyphBitmapCreate”的人,老实说,我对这到底是什么一无所知。
其他一些注意事项:“主页”按钮是在IB中创建的带有.png的自定义按钮。根据复选框的状态(我隐藏了一个,然后显示了另一个,反之亦然),我在两个.png之间切换(通过.hidden)的顶部上没有文本的“标记”按钮。
调用堆栈:
0 libSystem.B.dylib calloc
1 CoreGraphics CGGlyphBitmapCreate
2 CoreGraphics CGFontCreateGlyphBitmap8
3 CoreGraphics CGFontCreateGlyphBitmap
4 CoreGraphics CGGlyphLockLockGlyphBitmaps
5 libRIP.A.dylib ripc_DrawGlyphs
6 CoreGraphics draw_glyphs
7 CoreGraphics CGContextShowGlyphsWithAdvances
8 WebCore WebCore::showGlyphsWithAdvances(WebCore::FloatPoint const&, WebCore::SimpleFontData const*, CGContext*, unsigned short const*, CGSize const*, unsigned long)
9 WebCore WebCore::Font::drawGlyphs(WebCore::GraphicsContext*, WebCore::SimpleFontData const*, WebCore::GlyphBuffer const&, int, int, WebCore::FloatPoint const&, bool) const
10 WebCore WebCore::Font::drawSimpleText(WebCore::GraphicsContext*, WebCore::TextRun const&, WebCore::FloatPoint const&, int, int) const
11 WebCore WebCore::Font::drawText(WebCore::GraphicsContext*, WebCore::TextRun const&, WebCore::FloatPoint const&, int, int) const
12 WebKit drawAtPoint(unsigned short const*, int, WebCore::FloatPoint const&, WebCore::Font const&, WebCore::GraphicsContext*, bool, WebCore::BidiStatus*, int)
13 WebKit -[NSString(WebStringDrawing) __web_drawAtPoint:forWidth:withFont:ellipsis:letterSpacing:includeEmoji:measureOnly:renderedStringOut:drawUnderline:]
14 WebKit -[NSString(WebStringDrawing) __web_drawAtPoint:forWidth:withFont:ellipsis:letterSpacing:includeEmoji:measureOnly:renderedStringOut:]
15 WebKit -[NSString(WebStringDrawing) __web_drawAtPoint:forWidth:withFont:ellipsis:letterSpacing:includeEmoji:measureOnly:]
16 WebKit -[NSString(WebStringDrawing) _web_drawAtPoint:forWidth:withFont:ellipsis:letterSpacing:includeEmoji:]
17 UIKit -[NSString(UIStringDrawing) drawAtPoint:forWidth:withFont:lineBreakMode:letterSpacing:includeEmoji:]
18 UIKit -[NSString(UIStringDrawing) drawAtPoint:forWidth:withFont:fontSize:lineBreakMode:baselineAdjustment:includeEmoji:]
19 UIKit -[NSString(UIStringDrawing) drawAtPoint:forWidth:withFont:fontSize:lineBreakMode:baselineAdjustment:]
20 UIKit -[UILabel _drawTextInRect:baselineCalculationOnly:]
21 UIKit -[UILabel drawTextInRect:]
22 UIKit -[UILabel drawRect:]
23 UIKit -[UIView(CALayerDelegate) drawLayer:inContext:]
24 QuartzCore -[CALayer drawInContext:]
25 QuartzCore backing_callback(CGContext*, void*)
26 QuartzCore CABackingStoreUpdate_
27 QuartzCore CA::Layer::display_()
28 QuartzCore -[CALayer _display]
29 QuartzCore CA::Layer::display()
30 QuartzCore -[CALayer display]
31 QuartzCore CA::Layer::display_if_needed(CA::Transaction*)
32 QuartzCore CA::Context::commit_transaction(CA::Transaction*)
33 QuartzCore CA::Transaction::commit()
34 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
35 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
36 CoreFoundation __CFRunLoopDoObservers
37 CoreFoundation __CFRunLoopRun
38 CoreFoundation CFRunLoopRunSpecific
39 CoreFoundation CFRunLoopRunInMode
40 GraphicsServices GSEventRunModal
41 GraphicsServices GSEventRun
42 UIKit UIApplicationMain
43 MathProb main /Users/test/MathProb/main.m:14
44 MathProb start
Run Code Online (Sandbox Code Playgroud)
先感谢您。
您是否将 NSZombieEnabled 设置为 YES?我相信这可能会导致误报。验证您没有看到开发环境工件的一种方法是更改为发布模式:命令+选项+R,将运行设置为使用发布模式。然后,运行该应用程序。现在,在 iPad 上快速按两次主页按钮,终止该应用程序,然后正常从主屏幕启动它。我已经看到以这种方式启动时误报内存泄漏消失了。
归档时间: |
|
查看次数: |
1022 次 |
最近记录: |