Permalink
Browse files

Add example dtrace script for examining garbage collection

  • Loading branch information...
1 parent 25e3f23 commit f646e40eecad76f31ccba3ca1965447741eeb165 @crafterm crafterm committed Mar 8, 2008
Showing with 36 additions and 0 deletions.
  1. +25 −0 tools/dtrace/gc.d
  2. +11 −0 tools/dtrace/gc.rb
View
@@ -0,0 +1,25 @@
+/*
+ * garbage collection.
+ *
+ * This script prints statistics about the Rubinius garbage collectors as they're running
+ * to clean up memory.
+ *
+ * Example invocation:
+ *
+ * $> sudo dtrace -s gc.d -c 'rbx your-long-running-application.rb'
+ *
+ */
+
+#pragma D option quiet
+
+rubinius$target:::gc-begin
+{
+ in_use = arg1;
+ obj_count = arg2;
+}
+
+rubinius$target:::gc-end
+{
+ printf("Young GC size/use: %d/%d (freed %d bytes) %d/%d objects (%d delta)\n", arg0, arg1, in_use - arg1, obj_count, arg2, arg2 - obj_count);
+}
+
View
@@ -0,0 +1,11 @@
+GC.start
+GC.start
+GC.start
+GC.start
+GC.start
+GC.start
+GC.start
+GC.start
+Object.new
+GC.start
+GC.start

0 comments on commit f646e40

Please sign in to comment.