Skip to content

Instantly share code, notes, and snippets.

@tbodt
Created February 28, 2021 21:57
Show Gist options
  • Save tbodt/d8053c5fc9f66c9f182c9ea04a062e5e to your computer and use it in GitHub Desktop.
Save tbodt/d8053c5fc9f66c9f182c9ea04a062e5e to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -Cs
#pragma D option quiet
dtrace:::BEGIN {
printf("top outstanding allocation backtrace:\n");
printf("%d bytes in %d sampled allocations (sampling 1 in %d)\n", `top_ztrace->zt_size, `top_ztrace->zt_hit_count, `zleak_sample_factor);
printf("estimate: %d bytes in %d total allocations, %d bytes/allocation\n", `top_ztrace->zt_size * `zleak_sample_factor, `top_ztrace->zt_hit_count * `zleak_sample_factor, `top_ztrace->zt_size / `top_ztrace->zt_hit_count);
#define A(i) \
if (`top_ztrace->zt_depth > i) { \
sym((user_addr_t)`top_ztrace->zt_stack[i]); \
printf("\n"); \
}
A(0) A(1) A(2) A(3) A(4) A(5) A(6) A(7) A(8) A(9) A(10) A(11) A(12) A(13) A(14) A(15);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment