Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding a malloc_history dump
    primarykey
    data
    text
    <p>If you have ever asked how can I debug releasing/alloc issues in objective-c, you will have came across these environment settings that can help track the problem down:</p> <ul> <li><code>NSZombieEnabled</code> - Keeps abjects around after release, so you can get pointers etc.</li> <li><code>MallocStackLogging</code> - keeps object history for reference later </li> <li><code>NSDebugEnabled</code></li> </ul> <p>You set all of these to <code>YES</code> in the 'environment' section of the 'arguments' tab in the 'executables' (found in group tree) info.</p> <p><HR></p> <p>So, Im getting this console output</p> <blockquote> <p>MyApp [<strong>4413</strong>:40b] -[CALayer retainCount]: message sent to deallocated instance <strong>0x4dbb170</strong></p> </blockquote> <p>then open terminal, while the debugger has forwarded the break and type:</p> <blockquote> <p>malloc_history <strong>4413 0x4dbb170</strong></p> </blockquote> <p>Then, I get a big text dump, and as far as I understand the important bit is this:</p> <p>1</p> <pre><code>ALLOC 0x4dbb160-0x4dbb171 [size=18]: thread_a0375540 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoTimer | __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ | __NSFireDelayedPerform | -[todoListViewController drillDocumentMenu:] | -[documentListViewController drillIntoDocumentWithToDoRecord:] | -[documentViewController OpenTodoDocument:OfType:WithPath:] | -[documentViewController OpenDocumentOfType:WithPath:] | -[documentViewController managePDFDocumentWithPath:] | -[PDFDocument loadPDFDocumentWithPath:andTitle:] | -[PDFDocument getMetaData] | CGPDFDictionaryApplyFunction | ListDictionaryObjects(char const*, CGPDFObject*, void*) | NSLog | NSLogv | _CFLogvEx | __CFLogCString | asl_send | _asl_send_level_message | asl_set_query | strdup | malloc | malloc_zone_malloc </code></pre> <p>2</p> <pre><code>FREE 0x4dbb160-0x4dbb171 [size=18]: thread_a0375540 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoTimer | __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ | __NSFireDelayedPerform | -[todoListViewController drillDocumentMenu:] | -[documentListViewController drillIntoDocumentWithToDoRecord:] | -[documentViewController OpenTodoDocument:OfType:WithPath:] | -[documentViewController OpenDocumentOfType:WithPath:] | -[documentViewController managePDFDocumentWithPath:] | -[PDFDocument loadPDFDocumentWithPath:andTitle:] | -[PDFDocument getMetaData] | CGPDFDictionaryApplyFunction | ListDictionaryObjects(char const*, CGPDFObject*, void*) | NSLog | NSLogv | _CFLogvEx | __CFLogCString | asl_send | _asl_send_level_message | asl_free | free </code></pre> <p>3</p> <pre><code>ALLOC 0x4dbb170-0x4dbb19f [size=48]: thread_a0375540 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoTimer | __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ | __NSFireDelayedPerform | -[todoListViewController drillDocumentMenu:] | -[documentListViewController drillIntoDocumentWithToDoRecord:] | -[documentViewController OpenTodoDocument:OfType:WithPath:] | -[documentViewController OpenDocumentOfType:WithPath:] | -[documentViewController managePDFDocumentWithPath:] | -[ScrollViewWithPagingViewController init] | -[UIView init] | -[UIScrollView initWithFrame:] | -[UIView initWithFrame:] | UIViewCommonInitWithFrame | -[UIView _createLayerWithFrame:] | +[NSObject(NSObject) alloc] | +[NSObject(NSObject) allocWithZone:] | class_createInstance | _internal_class_createInstanceFromZone | calloc | malloc_zone_calloc </code></pre> <p><strong>What i don't understand though is if it the history was ALLOC,FREE,ALLOC then why does the error indicate that it was released (net +1 alloc)?</strong></p> <p><strong>or is my understanding of the dump wrong?</strong></p> <p><hr> EDIT (fresh run= different object pointers):</p> <p>Zombie Detection with instruments:</p> <p><img src="https://i140.photobucket.com/albums/r18/reeferx/zombies.png"/></p> <p>Why and how, does the retain count jump from 1 to -1?</p> <p>Looking at the backtrace of the Zombie, looks like the retain count is being called by: Quartz through release_root_if_unused</p> <p><img src="https://i140.photobucket.com/albums/r18/reeferx/stacktrace2.png"/> </p> <hr> <p>Edit: <strong>Solved</strong>- I was removing a view from super, then releasing it. Fixed by just releasing it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload