2011-12-02 23 views
4

這是昨天捎帶一個更廣泛的問題。我一直在使用heapshot來查明問題,但他們都在我不熟悉的調用者。我自己編寫的方法沒有顯示出來,但CoreGraphics似乎像瘋了一樣吃着記憶。程序運行時內存蠕變,CGGlyphBitmapCreate(等等)?

本週我都準備提交我的應用程序,但遇到了一個巨大的問題。我一直在做很多質量保證和泄漏檢測,並正在使用堆積/分配分析完成整個過程。不幸的是,這並沒有按計劃進行。該計劃本身並不是「泄漏」,但它毫無疑問正在攀升。

解釋該程序的最佳方式是數學閃卡(第一個應用程序,學習繩索,我想簡化它)。有5個按鈕,2個圖像視圖和2個UILabel。 我把頭撞到牆上,想知道我的設計是否是一個問題(可能是簡短回答),但更關心內存蠕變,這幾乎肯定不會讓我進入應用商店。

因此,進程: 該視圖顯示主頁按鈕(用於返回主菜單),複選框(用於稍後標記問題),UILabel中的數學問題以及獲取答覆按鈕。當您按下獲得答案時,答案將顯示在第二個UILabel中,並且會出現另外兩個按鈕(正確和錯誤),並且獲取答案按鈕標題更改爲「獲取問題」。按Get Get將我們重新設置爲開始,帶來一個新問題。

我一直在使用heapshot來查找正在佔用多少內存,並且我發現每次通過一次迭代後我都會丟失10-15KB(按「Get Answers」,然後按下「對還是錯」)。最壞的罪犯是被稱爲「CGGlyphBitmapCreate」,我真的很少知道它是什麼。

其他一些注意事項:「home」按鈕是一個自定義按鈕,帶有在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 

預先感謝您。

+1

'我想CGGlyphBitmapCreate'不是在真空中調用的。什麼叫它?那叫什麼?在通話堆上工作,直到找到你認可的東西。 –

+0

你正在使用哪種版本的iOS(或其模擬器)? –

+0

在黑暗中拍攝的一點點,但因爲它是低懸的成果:你是否有任何機會節省圖形狀態,從不讓它們退出? – Chuck

回答

0

你有NSZombieEnabled設置爲YES嗎?我相信這可能會導致誤報。一種驗證你沒有看到你的開發環境的工件的方法是改變到發佈模式:command + option + R,設置運行以使用發佈模式。然後,運行該應用程序。現在,快速在iPad上按兩次主頁按鈕,殺死應用程序,並正常從主屏幕啓動它。我發現以這種方式啓動時,假陽性內存泄漏消失。