xref: /netbsd-src/external/cddl/dtracetoolkit/dist/Docs/Examples/js_objgc_example.txt (revision c29d51755812ace2e87aeefdb06cb2b4dac7087a)
1*c29d5175SchristosFollowing are examples of running js_objgc.d.
2*c29d5175Schristos
3*c29d5175SchristosThis script reports on the garbage collection of Java objects.  That is it
4*c29d5175Schristoswill keep track of when resources are allocated to an object, and when
5*c29d5175Schristosresources are freed from an object.  It is useful for providing information on
6*c29d5175Schristoswhen garbage collection is not working correctly, as this can cause the
7*c29d5175Schristosbrowser to have a memory leak.
8*c29d5175Schristos
9*c29d5175SchristosWe trace object creation (+1) and destruction (-1), and provide a summary
10*c29d5175Schristoseach second of the running tally of the object class and originating filename.
11*c29d5175Schristos
12*c29d5175SchristosHere we can see it running on Code/JavaScript/func_clock.html
13*c29d5175Schristos
14*c29d5175Schristos# js_objgc.d
15*c29d5175SchristosTracing... Hit Ctrl-C to end.
16*c29d5175Schristos
17*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:24
18*c29d5175Schristos func_clock.html                 1 Date
19*c29d5175Schristos
20*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:25
21*c29d5175Schristos func_clock.html                 2 Date
22*c29d5175Schristos
23*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:26
24*c29d5175Schristos func_clock.html                 3 Date
25*c29d5175Schristos
26*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:27
27*c29d5175Schristos func_clock.html                 4 Date
28*c29d5175Schristos
29*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:28
30*c29d5175Schristos func_clock.html                 5 Date
31*c29d5175Schristos
32*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:29
33*c29d5175Schristos browser.js                      3 Function
34*c29d5175Schristos <null>                          5 Function
35*c29d5175Schristos func_clock.html                 6 Date
36*c29d5175Schristos <null>                          7 MouseEvent
37*c29d5175Schristos
38*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:30
39*c29d5175Schristos browser.js                      3 Function
40*c29d5175Schristos <null>                          5 Function
41*c29d5175Schristos func_clock.html                 7 Date
42*c29d5175Schristos <null>                         10 MouseEvent
43*c29d5175Schristos
44*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:31
45*c29d5175Schristos <null>                          1 Constructor
46*c29d5175Schristos <null>                          1 HTMLBodyElement
47*c29d5175Schristos <null>                          1 XPCNativeWrapper
48*c29d5175Schristos <null>                          1 XPC_WN_ModsAllowed_Proto_JSClass
49*c29d5175Schristos browser.js                      1 Array
50*c29d5175Schristos browser.js                      1 XPCNativeWrapper
51*c29d5175Schristos popup.xml                       1 Array
52*c29d5175Schristos func_clock.html                 7 Date
53*c29d5175Schristos <null>                         13 MouseEvent
54*c29d5175Schristos <null>                         18 Function
55*c29d5175Schristos browser.js                     20 Function
56*c29d5175Schristos
57*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 22:59:32
58*c29d5175Schristos <null>                          1 BoxObject
59*c29d5175Schristos <null>                          1 Constructor
60*c29d5175Schristos <null>                          1 HTMLBodyElement
61*c29d5175Schristos <null>                          1 NodeList
62*c29d5175Schristos <null>                          1 UIEvent
63*c29d5175Schristos <null>                          1 XPCNativeWrapper
64*c29d5175Schristos <null>                          1 XPC_WN_ModsAllowed_Proto_JSClass
65*c29d5175Schristos <null>                          1 chrome://global/content/bindings/menu.xml#menu-iconic 84ff45a
66*c29d5175Schristos <null>                          1 chrome://global/content/bindings/menu.xml#menu-iconic 8befbba
67*c29d5175Schristos bookmarksMenu.js                1 Function
68*c29d5175Schristos browser.js                      1 Array
69*c29d5175Schristos browser.js                      1 XPCNativeWrapper
70*c29d5175Schristos popup.xml                       1 Function
71*c29d5175Schristos scrollbox.xml                   1 Function
72*c29d5175Schristos <null>                          2 Event
73*c29d5175Schristos popup.xml                       2 Array
74*c29d5175Schristos bookmarks.js                    3 With
75*c29d5175Schristos firebug-service.js              3 Object
76*c29d5175Schristos bookmarks.js                    6 Object
77*c29d5175Schristos bookmarks.js                    6 XPCWrappedNative_NoHelper
78*c29d5175Schristos func_clock.html                 8 Date
79*c29d5175Schristos firebug-service.js             10 Function
80*c29d5175Schristos <null>                         15 MouseEvent
81*c29d5175Schristos bookmarks.js                   19 Error
82*c29d5175Schristos browser.js                     20 Function
83*c29d5175Schristos bookmarks.js                   22 Function
84*c29d5175Schristos <null>                         39 XPCWrappedNative_NoHelper
85*c29d5175Schristos <null>                         44 Function
86*c29d5175Schristos <null>                         60 RegExp
87*c29d5175Schristos <null>                        191 XULElement
88*c29d5175Schristos
89*c29d5175Schristos[... 39 seconds deleted ...]
90*c29d5175Schristos
91*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 23:00:10
92*c29d5175Schristos <null>                          1 HTMLBodyElement
93*c29d5175Schristos <null>                          1 HTMLCollection
94*c29d5175Schristos <null>                          1 TreeColumns
95*c29d5175Schristos <null>                          1 XPCNativeWrapper
96*c29d5175Schristos <null>                          1 XPC_WN_NoMods_Proto_JSClass
97*c29d5175Schristos <null>                          1 XULTreeBuilder
98*c29d5175Schristos <null>                          1 chrome://global/content/bindings/menu.xml#menu-iconic 84ff45a
99*c29d5175Schristos <null>                          1 chrome://global/content/bindings/menu.xml#menu-iconic 8befbba
100*c29d5175Schristos <null>                          1 chrome://global/content/bindings/tree.xml#treebody 84caa3a
101*c29d5175Schristos <null>                          1 chrome://global/content/bindings/tree.xml#treebody 84e3a72
102*c29d5175Schristos <null>                          1 nsXPCComponents_Interfaces
103*c29d5175Schristos <null>                          1 nsXPCComponents_Results
104*c29d5175Schristos bookmarksMenu.js                1 Function
105*c29d5175Schristos browser.js                      1 Array
106*c29d5175Schristos browser.js                      1 XPCNativeWrapper
107*c29d5175Schristos browser.js                      1 XPC_WN_NoMods_Proto_JSClass
108*c29d5175Schristos nsUpdateService.js              1 XPC_WN_NoMods_Proto_JSClass
109*c29d5175Schristos nsUpdateService.js              1 nsJSCID
110*c29d5175Schristos popup.xml                       1 Function
111*c29d5175Schristos scrollbar.xml                   1 String
112*c29d5175Schristos scrollbox.xml                   1 Function
113*c29d5175Schristos tree.xml                        1 Array
114*c29d5175Schristos <null>                          2 Constructor
115*c29d5175Schristos <null>                          2 UIEvent
116*c29d5175Schristos <null>                          2 XPC_WN_ModsAllowed_Proto_JSClass
117*c29d5175Schristos <null>                          2 nsXPCComponents_Classes
118*c29d5175Schristos browser.js                      2 nsJSCID
119*c29d5175Schristos browser.js                      2 nsJSIID
120*c29d5175Schristos utilityOverlay.js               2 nsJSCID
121*c29d5175Schristos utilityOverlay.js               2 nsJSIID
122*c29d5175Schristos <null>                          3 Array
123*c29d5175Schristos <null>                          3 NodeList
124*c29d5175Schristos nsUpdateService.js              3 Array
125*c29d5175Schristos nsUpdateService.js              3 Object
126*c29d5175Schristos nsUpdateService.js              3 With
127*c29d5175Schristos utilityOverlay.js               3 Call
128*c29d5175Schristos tree.xml                        4 Function
129*c29d5175Schristos utilityOverlay.js               4 Function
130*c29d5175Schristos nsUpdateService.js              7 nsJSIID
131*c29d5175Schristos nsUpdateService.js             15 Function
132*c29d5175Schristos bookmarks.js                   22 Function
133*c29d5175Schristos text.xml                       23 String
134*c29d5175Schristos <null>                         36 BoxObject
135*c29d5175Schristos func_clock.html                42 Date
136*c29d5175Schristos bookmarks.js                   57 With
137*c29d5175Schristos firebug-service.js             57 Object
138*c29d5175Schristos bookmarks.js                   73 Error
139*c29d5175Schristos browser.js                     78 Function
140*c29d5175Schristos popup.xml                      82 Array
141*c29d5175Schristos bookmarks.js                  114 Object
142*c29d5175Schristos bookmarks.js                  114 XPCWrappedNative_NoHelper
143*c29d5175Schristos <null>                        157 MouseEvent
144*c29d5175Schristos firebug-service.js            172 Function
145*c29d5175Schristos <null>                        307 XPCWrappedNative_NoHelper
146*c29d5175Schristos <null>                        388 RegExp
147*c29d5175Schristos <null>                        488 Event
148*c29d5175Schristos <null>                        876 XULElement
149*c29d5175Schristos <null>                       1221 Function
150*c29d5175Schristos
151*c29d5175Schristos FILE                        TOTAL CLASS                   2007 Sep 23 23:00:11
152*c29d5175Schristos <missed>                      -94 Date
153*c29d5175Schristos <missed>                      -34 Function
154*c29d5175Schristos <missed>                       -4 MouseEvent
155*c29d5175Schristos <missed>                       -2 Array
156*c29d5175Schristos <missed>                       -1 HTMLBodyElement
157*c29d5175Schristos <missed>                       -1 HTMLCollection
158*c29d5175Schristos <missed>                       -1 XPCNativeWrapper
159*c29d5175Schristos <missed>                       -1 XPC_WN_ModsAllowed_Proto_JSClass
160*c29d5175Schristos <null>                          0 Array
161*c29d5175Schristos <null>                          0 HTMLBodyElement
162*c29d5175Schristos <null>                          0 HTMLCollection
163*c29d5175Schristos <null>                          0 RegExp
164*c29d5175Schristos <null>                          0 TreeColumns
165*c29d5175Schristos <null>                          0 UIEvent
166*c29d5175Schristos <null>                          0 XPC_WN_NoMods_Proto_JSClass
167*c29d5175Schristos <null>                          0 XULTreeBuilder
168*c29d5175Schristos <null>                          0 nsXPCComponents_Classes
169*c29d5175Schristos <null>                          0 nsXPCComponents_Interfaces
170*c29d5175Schristos <null>                          0 nsXPCComponents_Results
171*c29d5175Schristos browser.js                      0 Array
172*c29d5175Schristos browser.js                      0 XPCNativeWrapper
173*c29d5175Schristos browser.js                      0 XPC_WN_NoMods_Proto_JSClass
174*c29d5175Schristos browser.js                      0 nsJSCID
175*c29d5175Schristos nsUpdateService.js              0 Array
176*c29d5175Schristos nsUpdateService.js              0 Function
177*c29d5175Schristos nsUpdateService.js              0 Object
178*c29d5175Schristos nsUpdateService.js              0 With
179*c29d5175Schristos nsUpdateService.js              0 XPC_WN_NoMods_Proto_JSClass
180*c29d5175Schristos nsUpdateService.js              0 nsJSCID
181*c29d5175Schristos nsUpdateService.js              0 nsJSIID
182*c29d5175Schristos scrollbar.xml                   0 String
183*c29d5175Schristos text.xml                        0 String
184*c29d5175Schristos tree.xml                        0 Array
185*c29d5175Schristos utilityOverlay.js               0 Call
186*c29d5175Schristos utilityOverlay.js               0 Function
187*c29d5175Schristos utilityOverlay.js               0 nsJSCID
188*c29d5175Schristos <null>                          1 NodeList
189*c29d5175Schristos <null>                          1 XPCNativeWrapper
190*c29d5175Schristos <null>                          1 chrome://global/content/bindings/menu.xml#menu-iconic 84ff45a
191*c29d5175Schristos <null>                          1 chrome://global/content/bindings/menu.xml#menu-iconic 8befbba
192*c29d5175Schristos <null>                          1 chrome://global/content/bindings/tree.xml#treebody 84caa3a
193*c29d5175Schristos <null>                          1 chrome://global/content/bindings/tree.xml#treebody 84e3a72
194*c29d5175Schristos bookmarksMenu.js                1 Function
195*c29d5175Schristos browser.xul                     1 Function
196*c29d5175Schristos func_clock.html                 1 Date
197*c29d5175Schristos popup.xml                       1 Function
198*c29d5175Schristos scrollbox.xml                   1 XULElement
199*c29d5175Schristos scrollbox.xml                   1 nsJSIID
200*c29d5175Schristos <null>                          2 Constructor
201*c29d5175Schristos <null>                          2 XPC_WN_ModsAllowed_Proto_JSClass
202*c29d5175Schristos browser.js                      2 nsJSIID
203*c29d5175Schristos scrollbox.xml                   2 Function
204*c29d5175Schristos tree.xml                        2 Function
205*c29d5175Schristos utilityOverlay.js               2 nsJSIID
206*c29d5175Schristos popup.xml                       3 Array
207*c29d5175Schristos bookmarks.js                    5 With
208*c29d5175Schristos firebug-service.js              5 Object
209*c29d5175Schristos <null>                          6 Event
210*c29d5175Schristos <null>                          6 MouseEvent
211*c29d5175Schristos bookmarks.js                    9 XPCWrappedNative_NoHelper
212*c29d5175Schristos <null>                         10 XPCWrappedNative_NoHelper
213*c29d5175Schristos bookmarks.js                   10 Object
214*c29d5175Schristos browser.js                     10 Function
215*c29d5175Schristos bookmarks.js                   15 Function
216*c29d5175Schristos firebug-service.js             16 Function
217*c29d5175Schristos <null>                         18 BoxObject
218*c29d5175Schristos bookmarks.js                   75 Error
219*c29d5175Schristos <null>                         79 Function
220*c29d5175Schristos <null>                        315 XULElement
221*c29d5175Schristos^C
222*c29d5175Schristos
223*c29d5175SchristosJust after time 23:00:10, garbage collection fired cleaning up many objects.
224*c29d5175SchristosThe final output shows a much reduced object count including a negative
225*c29d5175Schristoscount for objects created before this script was tracing.
226*c29d5175Schristos
227*c29d5175SchristosIf over the period of several minutes an object type is still steadily
228*c29d5175Schristosincreasing, then that would be of interest.  Be patient, depending on the rate
229*c29d5175Schristosof object creation it can take over ten minutes for garbage collect to kick in.
230*c29d5175Schristos
231