I was ready to send my first app to the app store. Checked for leaks, tested on devices, works. I wanted to make sure that my memory was under control, so I controlled the secretions and, alas, nothing was controlled.
I tested several areas of my application, but I focused on several large areas where constant use by the user could get the memory out of control very easily. The information from Allocations / Heapshots is hard for me to read, so I hope that someone out there can Rosetta Stone do it for me.
I will try to give as many details as possible, and if that is not enough, just scream and I will write more.
The application starts in the menu. When a button is clicked, a view appears through presentModalViewController. The view opens, and in the background the database opens and a random row is selected and saved. So, the cycle: Press "Main Menu" - "Open View" β "Close View", makes my memory grow at a speed of 10 KB-25 KB each time.
Some thoughts:
- Some parts of my presentation are created through IB, some of which are just a regular .png file. I read that an earlier build had problems freeing up and redistributing these resources, which caused a memory leak.
- I used button.layer.borderWidth / borderColor / cornerRadius / backgroundColor with some of my buttons that were originally created in IB. Is this no no? (Removing them helps a bit, but the problem still appears).
For the curious, this is the call stack for the largest heap growth:
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 GRE Words main /Users/admin/Dropbox/GRE Words/main.m:14 44 GRE Words start
If you think the code code will help, let me know. I felt that I was moving forward, and it was rather discouraging.
Thanks.