如果你曾經問我如何調試釋放/ Objective-C中的alloc的問題,你會在這些環境設置就可以幫助追蹤問題了下來:瞭解一個malloc_history轉儲
NSZombieEnabled
- 保持發佈後各地下流,這樣你就可以得到指針等MallocStackLogging
- 保留對象歷史以備日後參考NSDebugEnabled
您在「可執行文件」(可在組樹中找到)信息的「參數」選項卡的「環境」部分中將所有這些設置爲YES
。
所以,即時得到此控制檯輸出
MyApp的[:40B] - [CALayer的 retainCount]:消息發送到 釋放的實例0x4dbb170
然後打開終端,而調試器已轉發第Ë休息和類型:
malloc_history 4413 0x4dbb170
然後,我得到一個大的文本轉儲,而據我瞭解的重要一點是:
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
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
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
什麼,我不明白,雖然是,如果它的歷史被ALLOC,免費,ALLOC那麼爲什麼錯誤表明,它被釋放(淨+1 ALLOC)?
還是我對轉儲的理解錯誤?
EDIT(勁跑=不同的對象指針):
的殭屍檢測儀器有:
爲什麼和怎麼樣,不從1擋計數跳轉到-1?
望着殭屍的回溯,貌似保留計數被稱爲是:通過release_root_if_unused
石英
編輯:解決 - 我被去除超視圖,然後釋放它。通過發佈它來修復。
我認爲這個尺寸可能是一個指標。對象的id是開始地址,因此在塊3中分配的對象是引起我的問題的對象(因爲它的起始地址是在控制檯中報告的對象)。 – 2010-12-06 13:43:37
我不明白的是它在這裏清楚地表明它被分配。但錯誤表明它已被釋放... – 2010-12-06 13:44:41