Skip to content

Instantly share code, notes, and snippets.

@sophiawisdom
Last active April 25, 2020 16:40
Show Gist options
  • Save sophiawisdom/3f8e2459b7246abd64f798f41743f091 to your computer and use it in GitHub Desktop.
Save sophiawisdom/3f8e2459b7246abd64f798f41743f091 to your computer and use it in GitHub Desktop.
sophiawisdom@Sophias-MacBook-Pro tweaks % ./test_release
namesCount before is 10
namesCount after is 10
sophiawisdom@Sophias-MacBook-Pro tweaks %
#include <mach/mach_traps.h>
#include <mach/mach_types.h>
#include <mach/port.h>
int main() {
mach_port_name_array_t names;
int namesCount;
mach_port_type_array_t types;
int typesCount;
mach_port_names(mach_task_self(), &names, &namesCount, &types, &typesCount);
printf("namesCount before is %d\n", namesCount);
for (int i = 0; i < 1000; i++) {
int k = mach_thread_self();
int j = task_self_trap();
}
int newCount;
mach_port_names(mach_task_self(), &names, &newCount, &types, &typesCount);
printf("namesCount after is %d\n", namesCount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment