diff --git a/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCGetMainThreadUtil.mm b/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCGetMainThreadUtil.mm index a83dd877d..c29d59f8b 100644 --- a/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCGetMainThreadUtil.mm +++ b/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCGetMainThreadUtil.mm @@ -52,10 +52,12 @@ + (int)getCurrentMainThreadStack:(void (^)(NSUInteger pc))saveResultBlock KSThread currentThread = ksthread_self(); if (mainThread == currentThread) { + vm_deallocate(mach_task_self(), (vm_address_t)threads, sizeof(thread_t) * thread_count); return 0; } if (thread_suspend(mainThread) != KERN_SUCCESS) { + vm_deallocate(mach_task_self(), (vm_address_t)threads, sizeof(thread_t) * thread_count); return 0; } diff --git a/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCPowerConsumeStackCollector.mm b/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCPowerConsumeStackCollector.mm index a196d1469..c9daa56fb 100644 --- a/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCPowerConsumeStackCollector.mm +++ b/matrix/matrix-iOS/Matrix/WCCrashBlockMonitor/CrashBlockPlugin/Main/BlockMonitor/Handler/WCPowerConsumeStackCollector.mm @@ -613,6 +613,7 @@ + (float)getCurrentCPUUsage { mach_msg_type_number_t thread_info_count = THREAD_INFO_MAX; kr = thread_info(thread_list[j], THREAD_BASIC_INFO, (thread_info_t)thinfo, &thread_info_count); if (kr != KERN_SUCCESS) { + vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_t)); return -1; } thread_basic_info_t basic_info_th = (thread_basic_info_t)thinfo; @@ -661,6 +662,7 @@ - (float)getTotCpuWithCostCpuThreadArray:(NSMutableArray **)c mach_msg_type_number_t thread_info_count = THREAD_INFO_MAX; kr = thread_info(current_thread, THREAD_BASIC_INFO, (thread_info_t)thinfo, &thread_info_count); if (kr != KERN_SUCCESS) { + vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, *thread_count * sizeof(thread_t)); return -1; }