This is due to a broader question yesterday. I used heaps to identify problems, but they are all in callers that I donβt know. The methods that I wrote myself do not appear, but CoreGraphics seems to be eating memory like crazy.
I was about to submit my application this week, but ran into a huge problem. I did a lot of QA, and I discovered a leak, and ended the process with profiling using heapshot / distribution. Unfortunately, this is not as planned. The program is not a "leak" in itself, but it is steadily rising.
The best way to explain the program is with a math flash card (the first application that studies the ropes, I wanted to make it simple). There are 5 buttons, 2 images and 2 UILabels. I hit my head against the wall and wonder if my design is a problem (short answer: maybe), but Iβm more worried about creeping the memory, which will almost certainly not allow me to get to the application store.
So, the process: In the view, the Home button is displayed (to return to the main menu), a flag (to indicate a problem later), a mathematical problem in UILabel, and the Get Answer button. When you click "get an answer", the "Answer" is displayed in the second UILabel, and the other two buttons appear ("Right" and "Wrong"), and the heading "Get an answer" changes to "Get a problem." Clicking the Get Problem button brings us back to the beginning with a new problem.
I use heapshot to find out how much memory is occupied, and I found that I am losing between 10-15 KB every time I went through one iteration (by clicking "Get Answers", then clicking either "Right" or "Wrong"). The worst offender is called "CGGlyphBitmapCreate", which, frankly, I know little about what it really is.
Some other notes: the "home" button is a custom .png button created in IB. The button is "marked", not the text that is on top of two .png, which I switch between (via .hidden) depending on the state of the checkbox (I hide it, then show another, and vice versa).
Call stack:
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
Thanks in advance.