Skip to content

Instantly share code, notes, and snippets.

@Machx
Created March 8, 2010 17:42
Show Gist options
  • Save Machx/325392 to your computer and use it in GitHub Desktop.
Save Machx/325392 to your computer and use it in GitHub Desktop.
Invoke this script like so
./snow_leopard_garbage_collection.d -p [PID]
where pid is the process id of the app you are trying to trace
you may need to do
chmod +x snow_leopard_garbage_collection.d
to fix the permissions on the dtrace script so you can invoke it
#!/usr/sbin/dtrace -s
garbage_collection$target:::collection_begin
{
self->collectionString = (arg1 == 0 ? "full" : (arg1 == 1 ? "generational" : "local"));
self->collectionBeginTime = vtimestamp;
}
garbage_collection$target:::collection_end
{
self->collectionTotalTime = (vtimestamp - self->collectionBeginTime)/1000;
printf("\nDuration Time (ms) %d",self->collectionTotalTime);
printf("\n%d Objects Reclaimed (%d bytes) on Thread %x",(int)arg1,(int)arg2,tid);
printf("\nCollection Type: %s\n",self->collectionString);
printf("Bytes in use %d",(int)arg4);
printf(" Number in Use %d",(int)arg3);
ustack();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment