如何查找我们自己的内存管理问题?
打开活动监视器
CPU 找到PID
打开广告页面 等待奔溃 获取奔溃地址
2016-11-03 02:11:02.998 chengyuII iOS[70456:16227383] *** -[UIButton isKindOfClass:]: message sent to deallocated instance 0x7fc3311b6b20
sudo malloc_history PID 奔溃地址
sudo malloc_history 70456 0x7fc3311b6b20
Invalid connection: com.apple.coresymbolicationd
malloc_history Report Version: 2.0
ALLOC 0x7fc3311b6a50-0x7fc3311b6b97 [size=328]: thread_119984000 | start | main | UIApplicationMain | -[UIApplication _run] | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoSources0 | __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ | -[FBSSerialQueue _performNextFromRunLoopSource] | -[FBSSerialQueue _performNext] | __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ | -[UIApplication workspaceDidEndTransaction:] | -[UIApplication _runWithMainScene:transitionContext:completion:] | -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] | -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] | -[AppController application:didFinishLaunchingWithOptions:] | cocos2d::Application::run() | non-virtual thunk to AppDelegate::applicationDidFinishLaunching() | AppDelegate::applicationDidFinishLaunching() | AppDelegateBase::applicationDidFinishLaunching() | AppDelegateBase::doInit() | XXRegisterManager::doInitAfter(cocos2d::Ref*) | XXStageManagerBase::doInit(cocos2d::Ref*) | XXStageManagerBase::load() | XXStageManager::initStageData() | XXStageManager::loadStageDataFromFile() | XXStageManager::loadStageData() | XXStageManager::loadGameStageInfo() | cocos2d::__Dictionary::setObject(cocos2d::Ref*, long) | cocos2d::__Dictionary::setObjectUnSafe(cocos2d::Ref*, long) | operator new(unsigned long, std::nothrow_t const&) | operator new(unsigned long) | malloc
----
FREE 0x7fc3311b6a50-0x7fc3311b6b97 [size=328]: thread_119984000 | start | main | UIApplicationMain | GSEventRunModal | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoTimers | __CFRunLoopDoTimer | __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ | CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) | CA::Display::DisplayLinkItem::dispatch(unsigned long long) | -[CCDirectorCaller doCaller:] | cocos2d::DisplayLinkDirector::mainLoop() | cocos2d::AutoreleasePool::clear() | cocos2d::Ref::release() | cocos2d::__Dictionary::~__Dictionary() | cocos2d::__Dictionary::~__Dictionary() | cocos2d::__Dictionary::~__Dictionary() | cocos2d::__Dictionary::removeAllObjects()
ALLOC 0x7fc3311b69f0-0x7fc3311b6b47 [size=344]: thread_700000786000 | start_wqthread | _pthread_wqthread | _dispatch_worker_thread3 | _dispatch_root_queue_drain | _dispatch_queue_override_invoke | _dispatch_queue_invoke | _dispatch_queue_serial_drain | _dispatch_client_callout | cvm_deferred_build_modular(void*) | cvms_element_build_from_source | cvmsServerElementBuild | cvmsCompBuildElement | cvmsPluginElementBuild | glvmBuildFPTransformFunction | cvmAddOperationWithInline | cvmAddOperationWithInlines | llvm::Module::Materialize(llvm::GlobalValue*, std::__1::basic_string
----
FREE 0x7fc3311b69f0-0x7fc3311b6b47 [size=344]: thread_700000786000 | start_wqthread | _pthread_wqthread | _dispatch_worker_thread3 | _dispatch_root_queue_drain | _dispatch_queue_override_invoke | _dispatch_queue_invoke | _dispatch_queue_serial_drain | _dispatch_client_callout | cvm_deferred_build_modular(void*) | cvms_element_build_from_source | cvmsServerElementBuild | cvmsCompBuildElement | cvmsPluginElementBuild | glvmBuildFPTransformFunction | cvmEndModularFunction | llvm::BitcodeReader::Dematerialize(llvm::GlobalValue*) | llvm::Function::dropAllReferences() | llvm::iplist
ALLOC 0x7fc3311b6b20-0x7fc3311b6c67 [size=328]: thread_119984000 | start | main | UIApplicationMain | GSEventRunModal | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoSources0 | __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ | MultiplexerSource::_perform(void*) | MultiplexerSource::perform() | RunloopBlockContext::perform() | CFArrayApplyFunction | RunloopBlockContext::_invoke_block(void const*, void*) | _dispatch_block_invoke_direct | _dispatch_client_callout | ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 | ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke | -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] | -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] | __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke | 0x10e113c0d | 0x10e10f9ce | 0x10e11f1ad | __24-[YoumiVideo checkMedia]_block_invoke | 0x10e11f31d | 0x10e10da3c | 0x10e10e215 | 0x10e1108ef | -[UIDevice name] | -[UIDevice _deviceInfoForKey:] | 0x119992be1 | 0x1199937e1 | _SCPreferencesCopyComputerName | SCPreferencesPathGetValue | getPath | SCPreferencesGetValue | __SCPreferencesAccess | CFPropertyListCreateWithData | _CFPropertyListCreateWithData | _CFPropertyListCreateFromUTF8Data | parseXMLElement | getContentObject | parseXMLElement | getContentObject | parseXMLElement | getContentObject | parseXMLElement | getContentObject | parseXMLElement | CFDictionarySetValue | __CFBasicHashAddValue | __CFBasicHashRehash
----
FREE 0x7fc3311b6b20-0x7fc3311b6c67 [size=328]: thread_119984000 | start | main | UIApplicationMain | GSEventRunModal | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoSources0 | __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ | MultiplexerSource::_perform(void*) | MultiplexerSource::perform() | RunloopBlockContext::perform() | CFArrayApplyFunction | RunloopBlockContext::_invoke_block(void const*, void*) | _dispatch_block_invoke_direct | _dispatch_client_callout | ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 | ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke | -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] | -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] | __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke | 0x10e113c0d | 0x10e10f9ce | 0x10e11f1ad | __24-[YoumiVideo checkMedia]_block_invoke | 0x10e11f31d | 0x10e10da3c | 0x10e10e215 | 0x10e1108ef | -[UIDevice name] | -[UIDevice _deviceInfoForKey:] | 0x119992be1 | 0x1199937e1 | _SCPreferencesCopyComputerName | _CFRelease | __SCPreferencesDeallocate | _CFRelease | __CFBasicHashDrain | _CFRelease | __CFBasicHashDrain | _CFRelease | __CFBasicHashDrain | _CFRelease | __CFBasicHashDrain
ALLOC 0x7fc3311b6b20-0x7fc3311b6ddf [size=704]: thread_119984000 | start | main | UIApplicationMain | GSEventRunModal | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ | _dispatch_main_queue_callback_4CF | _dispatch_client_callout | _dispatch_call_block_and_release | __47-[ADAdapGDTNativeBanner nativeAdSuccessToLoad:]_block_invoke | -[ADAdapGDTNativeBanner showAdView] | +[UIButton buttonWithType:] | _objc_rootAlloc | class_createInstance | calloc
发现最后调用 ADAdapGDTNativeBanner showAdView 奔溃了
UIButton buttonWithType: 是最后的堆栈
sudo malloc_history 18 0x00007ffe413c36c0
XXADView* 0x00007ffe413c36c0
UIView* 0x00007ffe3b515de0
m_adView 0x00007ffe410eb930
m_nativeAd 0x00006080004922f0