aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/dtracetoolkit/Examples/py_mallocstk_example.txt
blob: a466737f34b27ae37fae41708e5bc48ca3b9a4c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
Following are examples of running py_mallocstk.d.  This traces malloc() from
Python, printing byte distributions by user stack trace.

Here we see the script runnin on the program Code/Python/func_abc.py

# py_mallocstk.d -c ./func_abc.py

Tracing... Hit Ctrl-C to end.
Function A
Function B
Function C

Python malloc byte distributions by stack trace,



              libc.so.1`malloc
              libpython2.4.so.1.0`r_object+0x52f
              libpython2.4.so.1.0`r_object+0x491
              libpython2.4.so.1.0`r_object+0xd3
              libpython2.4.so.1.0`r_object+0x491
              libpython2.4.so.1.0`r_object+0xd3
              libpython2.4.so.1.0`r_object+0x491
              libpython2.4.so.1.0`r_object+0xd3
              libpython2.4.so.1.0`PyMarshal_ReadObjectFromString+0x36
              libpython2.4.so.1.0`PyMarshal_ReadLastObjectFromFile+0x6a
              libpython2.4.so.1.0`read_compiled_module+0xf
              libpython2.4.so.1.0`load_source_module+0x63
              libpython2.4.so.1.0`load_module+0xac
              libpython2.4.so.1.0`import_submodule+0xfb
              libpython2.4.so.1.0`load_next+0xee
              libpython2.4.so.1.0`import_module_ex+0x48
              libpython2.4.so.1.0`PyImport_ImportModuleEx+0x1d
              libpython2.4.so.1.0`builtin___import__+0x4e
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`PyObject_Call+0x1d
              libpython2.4.so.1.0`PyEval_CallObjectWithKeywords+0xb8
              libpython2.4.so.1.0`PyEval_EvalFrame+0xd3c
                [ /usr/lib/python2.4/encodings/__init__.py:28 (?) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`PyEval_EvalCode+0x22
              libpython2.4.so.1.0`PyImport_ExecCodeModuleEx+0xc0
              libpython2.4.so.1.0`load_source_module+0xe6
              libpython2.4.so.1.0`load_module+0xac
              libpython2.4.so.1.0`load_package+0xef
              libpython2.4.so.1.0`load_module+0x6a
              libpython2.4.so.1.0`import_submodule+0xfb
              libpython2.4.so.1.0`load_next+0xa2
              libpython2.4.so.1.0`import_module_ex+0x48
              libpython2.4.so.1.0`PyImport_ImportModuleEx+0x1d
              libpython2.4.so.1.0`_PyCodecRegistry_Init+0xce
              libpython2.4.so.1.0`_PyCodec_Lookup+0x2a
              libpython2.4.so.1.0`PyCodec_Encoder+0xf
              libpython2.4.so.1.0`Py_InitializeEx+0x257
              libpython2.4.so.1.0`Py_Initialize+0xd
              libpython2.4.so.1.0`Py_Main+0x4db
              python`main+0x11
              python`_start+0x7a

           value  ------------- Distribution ------------- count    
               0 |                                         0        
               1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1        
               2 |                                         0        


              libc.so.1`malloc
              libpython2.4.so.1.0`_PyUnicode_New+0xb2
              libpython2.4.so.1.0`_PyUnicodeUCS2_Init+0x19
              libpython2.4.so.1.0`Py_InitializeEx+0x11c
              libpython2.4.so.1.0`Py_Initialize+0xd
              libpython2.4.so.1.0`Py_Main+0x4db
              python`main+0x11
              python`_start+0x7a

           value  ------------- Distribution ------------- count    
               1 |                                         0        
               2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1        
               4 |                                         0        


              libc.so.1`malloc
              libc.so.1`_real_gettext_u+0x81
              libc.so.1`dgettext+0x5e
              libc.so.1`strerror+0x40
              libpython2.4.so.1.0`PyErr_SetFromErrnoWithFilenameObject+0x2d
              libpython2.4.so.1.0`PyErr_SetFromErrnoWithFilename+0x27
              libpython2.4.so.1.0`posix_error_with_allocated_filename+0x17
              libpython2.4.so.1.0`posix_do_stat+0x21f
              libpython2.4.so.1.0`posix_stat+0x1f
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`call_function+0x406
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/posixpath.py:195 (isdir) ]
              libpython2.4.so.1.0`fast_function+0xa8
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:202 (addsitepackages) ]
              libpython2.4.so.1.0`fast_function+0xa8
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:382 (main) ]
              libpython2.4.so.1.0`fast_function+0xa8
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:397 (?) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`PyEval_EvalCode+0x22
              libpython2.4.so.1.0`PyImport_ExecCodeModuleEx+0xc0
              libpython2.4.so.1.0`load_source_module+0xe6
              libpython2.4.so.1.0`load_module+0xac
              libpython2.4.so.1.0`import_submodule+0xfb
              libpython2.4.so.1.0`load_next+0xa2
              libpython2.4.so.1.0`import_module_ex+0x48
              libpython2.4.so.1.0`PyImport_ImportModuleEx+0x1d
              libpython2.4.so.1.0`builtin___import__+0x4e
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`PyObject_Call+0x1d
              libpython2.4.so.1.0`PyObject_CallFunction+0x90
              libpython2.4.so.1.0`PyImport_Import+0x163
              libpython2.4.so.1.0`PyImport_ImportModule+0x1f
              libpython2.4.so.1.0`initsite+0x10
              libpython2.4.so.1.0`Py_InitializeEx+0x1ea
              libpython2.4.so.1.0`Py_Initialize+0xd
              libpython2.4.so.1.0`Py_Main+0x4db
              python`main+0x11
              python`_start+0x7a

           value  ------------- Distribution ------------- count    
               1 |                                         0        
               2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1        
               4 |                                         0        

[... around 17000 lines truncated ...]


              libc.so.1`malloc
              libpython2.4.so.1.0`PyObject_Malloc+0x126
              libpython2.4.so.1.0`fixstate+0x26
              libpython2.4.so.1.0`fixdfa+0x2a
              libpython2.4.so.1.0`PyGrammar_AddAccelerators+0x1b
              libpython2.4.so.1.0`PyParser_New+0x18
              libpython2.4.so.1.0`parsetok+0x17
              libpython2.4.so.1.0`PyParser_ParseStringFlagsFilename+0x72
              libpython2.4.so.1.0`PyParser_ParseStringFlags+0x1c
              libpython2.4.so.1.0`PyParser_SimpleParseStringFlags+0x23
              libpython2.4.so.1.0`PyRun_StringFlags+0x2c
              libpython2.4.so.1.0`builtin_eval+0x273
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`call_function+0x406
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/os.py:503 (_exists) ]
              libpython2.4.so.1.0`fast_function+0xa8
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/os.py:509 (?) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`PyEval_EvalCode+0x22
              libpython2.4.so.1.0`PyImport_ExecCodeModuleEx+0xc0
              libpython2.4.so.1.0`load_source_module+0xe6
              libpython2.4.so.1.0`load_module+0xac
              libpython2.4.so.1.0`import_submodule+0xfb
              libpython2.4.so.1.0`load_next+0xa2
              libpython2.4.so.1.0`import_module_ex+0x48
              libpython2.4.so.1.0`PyImport_ImportModuleEx+0x1d
              libpython2.4.so.1.0`builtin___import__+0x4e
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`PyObject_Call+0x1d
              libpython2.4.so.1.0`PyEval_CallObjectWithKeywords+0xb8
              libpython2.4.so.1.0`PyEval_EvalFrame+0xd3c
                [ /usr/lib/python2.4/site.py:58 (?) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`PyEval_EvalCode+0x22
              libpython2.4.so.1.0`PyImport_ExecCodeModuleEx+0xc0
              libpython2.4.so.1.0`load_source_module+0xe6
              libpython2.4.so.1.0`load_module+0xac
              libpython2.4.so.1.0`import_submodule+0xfb
              libpython2.4.so.1.0`load_next+0xa2
              libpython2.4.so.1.0`import_module_ex+0x48
              libpython2.4.so.1.0`PyImport_ImportModuleEx+0x1d
              libpython2.4.so.1.0`builtin___import__+0x4e
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`PyObject_Call+0x1d
              libpython2.4.so.1.0`PyObject_CallFunction+0x90
              libpython2.4.so.1.0`PyImport_Import+0x163
              libpython2.4.so.1.0`PyImport_ImportModule+0x1f
              libpython2.4.so.1.0`initsite+0x10
              libpython2.4.so.1.0`Py_InitializeEx+0x1ea
              libpython2.4.so.1.0`Py_Initialize+0xd
              libpython2.4.so.1.0`Py_Main+0x4db
              python`main+0x11
              python`_start+0x7a

           value  ------------- Distribution ------------- count    
             256 |                                         0        
             512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 331      
            1024 |                                         0        


              libc.so.1`malloc
              libpython2.4.so.1.0`new_arena+0x13
              libpython2.4.so.1.0`PyObject_Malloc+0x91
              libpython2.4.so.1.0`string_concat+0x109
              libpython2.4.so.1.0`PyString_Concat+0x3b
              libpython2.4.so.1.0`string_concatenate+0x150
              libpython2.4.so.1.0`PyEval_EvalFrame+0x27cc
                [ /usr/lib/python2.4/posixpath.py:62 (join) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`function_call+0x15e
              libpython2.4.so.1.0`PyObject_Call+0x1d
              libpython2.4.so.1.0`ext_do_call+0xfb
              libpython2.4.so.1.0`PyEval_EvalFrame+0xb4f
                [ /usr/lib/python2.4/site.py:66 (makepath) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`fast_function+0x112
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:138 (addpackage) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`fast_function+0x112
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:166 (addsitedir) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`fast_function+0x112
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ <string>:1 (?) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`PyEval_EvalCode+0x22
              libpython2.4.so.1.0`run_node+0x35
              libpython2.4.so.1.0`run_err_node+0x1f
              libpython2.4.so.1.0`PyRun_String+0x27
              libpython2.4.so.1.0`exec_statement+0x2b0
              libpython2.4.so.1.0`PyEval_EvalFrame+0x15d6
                [ /usr/lib/python2.4/site.py:134 (addpackage) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`fast_function+0x112
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:166 (addsitedir) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`fast_function+0x112
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:203 (addsitepackages) ]
              libpython2.4.so.1.0`fast_function+0xa8
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:382 (main) ]
              libpython2.4.so.1.0`fast_function+0xa8
              libpython2.4.so.1.0`call_function+0xda
              libpython2.4.so.1.0`PyEval_EvalFrame+0xbdf
                [ /usr/lib/python2.4/site.py:397 (?) ]
              libpython2.4.so.1.0`PyEval_EvalCodeEx+0x732
              libpython2.4.so.1.0`PyEval_EvalCode+0x22
              libpython2.4.so.1.0`PyImport_ExecCodeModuleEx+0xc0
              libpython2.4.so.1.0`load_source_module+0xe6
              libpython2.4.so.1.0`load_module+0xac
              libpython2.4.so.1.0`import_submodule+0xfb
              libpython2.4.so.1.0`load_next+0xa2
              libpython2.4.so.1.0`import_module_ex+0x48
              libpython2.4.so.1.0`PyImport_ImportModuleEx+0x1d
              libpython2.4.so.1.0`builtin___import__+0x4e
              libpython2.4.so.1.0`PyCFunction_Call+0x15f
              libpython2.4.so.1.0`PyObject_Call+0x1d
              libpython2.4.so.1.0`PyObject_CallFunction+0x90
              libpython2.4.so.1.0`PyImport_Import+0x163
              libpython2.4.so.1.0`PyImport_ImportModule+0x1f
              libpython2.4.so.1.0`initsite+0x10
              libpython2.4.so.1.0`Py_InitializeEx+0x1ea
              libpython2.4.so.1.0`Py_Initialize+0xd
              libpython2.4.so.1.0`Py_Main+0x4db

           value  ------------- Distribution ------------- count    
          131072 |                                         0        
          262144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1        
          524288 |                                         0        


              libc.so.1`malloc
              libpython2.4.so.1.0`new_arena+0x13
              libpython2.4.so.1.0`PyObject_Malloc+0x91
              libpython2.4.so.1.0`_PyObject_GC_Malloc+0x13
              libpython2.4.so.1.0`_PyObject_GC_NewVar+0x24
              libpython2.4.so.1.0`PyTuple_New+0x78
              libpython2.4.so.1.0`PyType_Ready+0x98
              libpython2.4.so.1.0`PyType_Ready+0x60
              libpython2.4.so.1.0`_Py_ReadyTypes+0x10
              libpython2.4.so.1.0`Py_InitializeEx+0xed
              libpython2.4.so.1.0`Py_Initialize+0xd
              libpython2.4.so.1.0`Py_Main+0x4db
              python`main+0x11
              python`_start+0x7a

           value  ------------- Distribution ------------- count    
          131072 |                                         0        
          262144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1        
          524288 |                                         0        


This output looks a little  unusual at first glance, and can be confusing for
people unfamiliar with stack tracing and Python engine internals. 

Start by looking at the distribution plots below each stack trace - each plot
shows how many bytes were requested as a histogram by byte size.  This should
indicated to you if python is malloc()ing much memory or not, and whether it
is doing so in a few large malloc()s or many small ones.

With this information in mind you can inspect the stack traces - these explain
why Python called malloc() in that instance, along with translations of Python
functions buried in the stack trace.  The stack traces can be hard to read at
first (or even at second or at third) - since you are examining Python engine
internals. Try looking for lines in square brackets - those are Python language 
frames, and will show where (or if) the malloc() was caused by Python code.