首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >程序运行时内存爬行,CGGlyphBitmapCreate (以及其他)?

程序运行时内存爬行,CGGlyphBitmapCreate (以及其他)?
EN

Stack Overflow用户
提问于 2011-12-03 02:31:01
回答 1查看 1K关注 0票数 5

这是昨天提出的一个更广泛的问题。我一直在使用heapshot来定位问题,但它们都在我不熟悉的调用者中。我自己编写的方法没有出现,但CoreGraphics似乎正在疯狂地消耗内存。

我本打算在这周提交我的应用程序,但遇到了一个大问题。我已经做了很多QA和泄漏检测,并使用heapshot/分配分析完成了这个过程。不幸的是,这并没有按计划进行。该程序本身并没有“泄漏”,但它无疑正在攀升。

解释这个程序的最好方法是一张数学抽认卡(第一个应用程序,学习技巧,我想让它变得简单)。有5个按钮,2个图像视图和2个UILabels。我的头撞到了墙上,想知道我的设计是不是有问题(简单的答案是:可能),但更担心的是记忆蠕动,几乎肯定不会让我进入应用商店。

因此,流程如下:视图显示一个Home按钮(用于返回主菜单)、一个复选框(用于标记稍后要解决的问题)、一个UILabel中的数学问题和一个Get Answer按钮。当您按下get answer时,答案将显示在第二个UILabel中,并且还会出现两个按钮(正确和错误),并且Get Answer按钮的标题将更改为"Get Problem“。按Get problem将我们重新设置为具有新问题的开始。

我一直在使用heapshot来找出占用了多少内存,并且我发现每次我完成一次迭代(按“获取答案”,然后按“正确”或“错误”)时,我会损失10-15KB。最糟糕的罪犯是所谓的"CGGlyphBitmapCreate“,老实说,我对它的实际情况知之甚少。

其他注意事项:“主页”按钮是在IB中创建的带有.png的自定义按钮。我根据复选框的状态(通过.hidden)在两个.pngs之间切换(我隐藏一个,然后显示另一个,反之亦然)上的“标记”按钮上没有文本。

调用堆栈:

代码语言:javascript
复制
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

提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2012-04-19 13:16:21

是否将NSZombieEnabled设置为YES?我相信这可能会导致误报。验证您没有看到开发环境中的工件的一种方法是更改为发布模式: command+option+R,将run设置为使用release模式。然后,运行应用程序。现在,快速按下iPad上的主键两次,关闭应用程序,并正常从主屏幕启动它。我看到过以这种方式启动时,误报内存泄漏会消失。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8360910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档