Si alguna vez se preguntó ¿cómo puedo eliminar errores de liberación/cuestiones alloc en Objective-C, se le han encontré con estos valores de entorno que puede ayudar a rastrear el problema abajo:La comprensión de un vertedero malloc_history
NSZombieEnabled
- Keeps despreciables alrededor después de la liberación, para que pueda obtener punteros etc.MallocStackLogging
- mantiene historial del objeto para su posterior consultaNSDebugEnabled
Los configura todos a YES
en la sección 'entorno' de la pestaña 'argumentos' en la información 'ejecutables' (se encuentra en el árbol de grupos).
Por lo tanto, Im conseguir este resultado de la consola
MiApl [: 40b] - [CALayer retainCount]: mensaje enviado a ejemplo desasignado 0x4dbb170
luego abra la terminal, mientras que el depurador ha reenviado e ruptura y tipo:
malloc_history 4413 0x4dbb170
A continuación, aparece un gran vertedero de texto, y por lo que yo entiendo la parte importante es la siguiente:
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
Lo que no entiendo es sin embargo si la historia se ALLOC, GRATIS, ALLOC entonces ¿Qué indica el error que fue puesto en libertad (neto 1 alloc)?
o mi comprensión del volcado es incorrecta?
EDIT (fresca Run = diferentes punteros de objeto):
detección del zombi con los instrumentos:
¿Por qué y cómo, hace el recuento de salto retener de 1 a -1?
En cuanto a la traza del zombi, se parece a la cuenta de retención está siendo llamado por: Cuarzo través release_root_if_unused
Editar: Resuelto - Me estaba quitando una vista desde super , luego soltándolo. Solucionado con solo liberarlo.
Pregunta editada para mostrar los resultados de sus recomendaciones. –
Gracias por su ayuda con esto, rastreó el problema: estaba eliminando una vista de super que tenía una vista secundaria y una capa secundaria (grand), y luego solté la vista después de esto. En cambio, ahora solo lanzo. Solo comenzó a suceder desde que actualicé la aplicación a 4.2 (ipad) - Así que aprendí la lección. Gracias de nuevo. –