Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -661,6 +662,7 @@ - (float)getTotCpuWithCostCpuThreadArray:(NSMutableArray<WCCpuStackFrame *> **)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;
}

Expand Down