3 * js_objgc.d - trace JavaScript Object GC using DTrace.
4 * Written for the JavaScript DTrace provider.
6 * $Id: js_objgc.d 63 2007-10-04 04:34:38Z brendan $
8 * This traces JavaScript activity from all running browers on the system
9 * which support the JavaScript DTrace provider.
11 * USAGE: js_objgc.d # hit Ctrl-C to end
14 * FILE Filename that contained the function
15 * CLASS Class to which this new object belongs
16 * TOTAL Object entropy (positive == uncollected)
18 * This script provides information on which objects are not being garbage
19 * collected, an issue which causes the browser to steadily leak memory.
20 * We trace object creation (+1) and destruction (-1), and provide a
21 * summary each second of the running tally of the object class and
22 * originating filename. If over the period of several minutes an object
23 * type is still steadily increasing, then that would be of interest.
24 * Be patient, depending on the rate of object creation it can take over
25 * ten minutes for garbage collect to kick in.
28 * - it is possible that you will see negative entropy. That happens
29 * when you begin tracing after some objects have already been created,
30 * and then trace their destruction.
31 * - there are other Things that GC handles, other than Objects; extra
32 * probes can be added to trace them, should the need arise.
34 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
38 * The contents of this file are subject to the terms of the
39 * Common Development and Distribution License, Version 1.0 only
40 * (the "License"). You may not use this file except in compliance
43 * You can obtain a copy of the license at Docs/cddl1.txt
44 * or http://www.opensolaris.org/os/licensing.
45 * See the License for the specific language governing permissions
46 * and limitations under the License.
50 * 09-Sep-2007 Brendan Gregg Created this.
53 /* if you get dynvardrops, increase this, */
54 #pragma D option dynvarsize=32m
55 #pragma D option quiet
59 printf("Tracing... Hit Ctrl-C to end.\n");
62 javascript*:::object-create
65 this->file = basename(copyinstr(arg0));
66 @objs[this->file, copyinstr(arg1)] = sum(1);
67 filename[arg2] = this->file;
70 javascript*:::object-finalize
71 /filename[arg2] == NULL/
73 @objs["<missed>", copyinstr(arg1)] = sum(-1);
76 javascript*:::object-finalize
77 /filename[arg2] != NULL/
79 @objs[filename[arg2], copyinstr(arg1)] = sum(-1);
86 printf("\n %-24s %8s %-20s %23Y\n", "FILE", "TOTAL", "CLASS",
88 printa(" %-24.24s %@8d %s\n", @objs);