1 The following are examples of py_malloc.d
3 This is an experimental script to identify who is calling malloc() for memory
4 allocation, and to print distribution plots of the requested bytes. Here you
5 can see it running on Code/Python/func_abc.py
7 # py_malloc.d -c ./func_abc.py
8 Tracing... Hit Ctrl-C to end.
13 Python malloc byte distributions by engine caller,
15 libpython2.4.so.1.0`_PyUnicode_New, total bytes = 2
16 value ------------- Distribution ------------- count
18 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
21 libpython2.4.so.1.0`find_key, total bytes = 16
22 value ------------- Distribution ------------- count
24 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
27 libpython2.4.so.1.0`PyInterpreterState_New, total bytes = 36
28 value ------------- Distribution ------------- count
30 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
33 libpython2.4.so.1.0`_PyImport_Init, total bytes = 60
34 value ------------- Distribution ------------- count
36 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
39 libpython2.4.so.1.0`PyThreadState_New, total bytes = 84
40 value ------------- Distribution ------------- count
42 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
45 libpython2.4.so.1.0`pmerge, total bytes = 132
46 value ------------- Distribution ------------- count
49 8 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 16
52 libpython2.4.so.1.0`PyThread_allocate_lock, total bytes = 144
53 value ------------- Distribution ------------- count
55 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
58 libpython2.4.so.1.0`convertsimple, total bytes = 210
59 value ------------- Distribution ------------- count
61 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5
64 libc.so.1`strdup, total bytes = 451
65 value ------------- Distribution ------------- count
70 16 |@@@@@@@@@@@@@@@@@@@@ 8
74 libpython2.4.so.1.0`PyList_New, total bytes = 528
75 value ------------- Distribution ------------- count
77 4 |@@@@@@@@@@@@@@@@@@ 22
78 8 |@@@@@@@@@@@@@@@@@ 21
85 libpython2.4.so.1.0`PyTokenizer_FromFile, total bytes = 1024
86 value ------------- Distribution ------------- count
88 1024 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
91 libpython2.4.so.1.0`_PyExc_Init, total bytes = 1058
92 value ------------- Distribution ------------- count
94 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 40
98 libpython2.4.so.1.0`tok_new, total bytes = 1832
99 value ------------- Distribution ------------- count
101 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
104 libpython2.4.so.1.0`fill_free_list, total bytes = 1976
105 value ------------- Distribution ------------- count
107 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
110 libpython2.4.so.1.0`PyParser_New, total bytes = 12024
111 value ------------- Distribution ------------- count
113 4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
116 libpython2.4.so.1.0`PyObject_Malloc, total bytes = 35152
117 value ------------- Distribution ------------- count
119 256 |@@@@@@@@@@@@@@@@@@@ 20
125 libpython2.4.so.1.0`PyMem_Malloc, total bytes = 50683
126 value ------------- Distribution ------------- count
141 libc.so.1`_findbuf, total bytes = 51800
142 value ------------- Distribution ------------- count
144 512 |@@@@@@@@@@@@@@@ 4
148 8192 |@@@@@@@@@@@@@@@ 4
151 libpython2.4.so.1.0`dictresize, total bytes = 178752
152 value ------------- Distribution ------------- count
155 256 |@@@@@@@@@@@@@@@@@@@@@ 29
157 1024 |@@@@@@@@@@@@@@ 19
166 libpython2.4.so.1.0`new_arena, total bytes = 262208
167 value ------------- Distribution ------------- count
169 64 |@@@@@@@@@@@@@@@@@@@@ 1
181 262144 |@@@@@@@@@@@@@@@@@@@@ 1
185 Python malloc byte distributions by Python file and function,
187 site.py, addsitepackages, bytes total = 4
188 value ------------- Distribution ------------- count
190 4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
193 site.py, abs__file__, bytes total = 60
194 value ------------- Distribution ------------- count
196 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
199 posixpath.py, exists, bytes total = 83
200 value ------------- Distribution ------------- count
202 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
205 stat.py, S_ISDIR, bytes total = 364
206 value ------------- Distribution ------------- count
208 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
211 site.py, _init_pathinfo, bytes total = 380
212 value ------------- Distribution ------------- count
214 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
217 UserDict.py, DictMixin, bytes total = 384
218 value ------------- Distribution ------------- count
220 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
223 codecs.py, StreamReader, bytes total = 384
224 value ------------- Distribution ------------- count
226 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
229 codecs.py, StreamReaderWriter, bytes total = 384
230 value ------------- Distribution ------------- count
232 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
235 codecs.py, StreamRecoder, bytes total = 384
236 value ------------- Distribution ------------- count
238 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
241 codecs.py, StreamWriter, bytes total = 384
242 value ------------- Distribution ------------- count
244 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
247 os.py, _Environ, bytes total = 384
248 value ------------- Distribution ------------- count
250 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
253 site.py, _Printer, bytes total = 384
254 value ------------- Distribution ------------- count
256 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
259 site.py, addsitedir, bytes total = 388
260 value ------------- Distribution ------------- count
262 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
265 linecache.py, ?, bytes total = 396
266 value ------------- Distribution ------------- count
268 8 |@@@@@@@@@@@@@@@@@@@@ 1
273 256 |@@@@@@@@@@@@@@@@@@@@ 1
276 posixpath.py, isdir, bytes total = 608
277 value ------------- Distribution ------------- count
282 16 |@@@@@@@@@@@@@@@@@@@@@@@ 7
289 os.py, _get_exports_list, bytes total = 612
290 value ------------- Distribution ------------- count
292 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
295 posixpath.py, abspath, bytes total = 728
296 value ------------- Distribution ------------- count
298 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
301 site.py, execsitecustomize, bytes total = 790
302 value ------------- Distribution ------------- count
304 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
310 UserDict.py, UserDict, bytes total = 1920
311 value ------------- Distribution ------------- count
313 256 |@@@@@@@@@@@@@@@@@@@@ 1
315 1024 |@@@@@@@@@@@@@@@@@@@@ 1
318 stat.py, ?, bytes total = 1920
319 value ------------- Distribution ------------- count
321 256 |@@@@@@@@@@@@@@@@@@@@ 1
323 1024 |@@@@@@@@@@@@@@@@@@@@ 1
326 types.py, ?, bytes total = 2680
327 value ------------- Distribution ------------- count
335 256 |@@@@@@@@@@@@@@@@@ 3
340 posixpath.py, ?, bytes total = 3306
341 value ------------- Distribution ------------- count
343 16 |@@@@@@@@@@@@@@@@ 2
347 256 |@@@@@@@@@@@@@@@@ 2
353 copy_reg.py, ?, bytes total = 3547
354 value ------------- Distribution ------------- count
356 16 |@@@@@@@@@@@@@@@@ 2
366 warnings.py, ?, bytes total = 3924
367 value ------------- Distribution ------------- count
373 256 |@@@@@@@@@@@@@@@@ 2
379 func_abc.py, func_a, bytes total = 5100
380 value ------------- Distribution ------------- count
382 512 |@@@@@@@@@@@@@@@@@@@@ 1
385 4096 |@@@@@@@@@@@@@@@@@@@@ 1
388 codecs.py, ?, bytes total = 5612
389 value ------------- Distribution ------------- count
395 1024 |@@@@@@@@@@@@@@@@@ 3
398 aliases.py, ?, bytes total = 8064
399 value ------------- Distribution ------------- count
403 1024 |@@@@@@@@@@@@@ 1
405 4096 |@@@@@@@@@@@@@ 1
408 func_abc.py, ?, bytes total = 16105
409 value ------------- Distribution ------------- count
425 os.py, ?, bytes total = 58957
426 value ------------- Distribution ------------- count
434 256 |@@@@@@@@@@@@@@@@@@ 23
442 site.py, ?, bytes total = 62589
443 value ------------- Distribution ------------- count
449 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 20
458 __init__.py, ?, bytes total = 62593
459 value ------------- Distribution ------------- count
470 512 |@@@@@@@@@@@@@@@@ 10
478 posixpath.py, join, bytes total = 262144
479 value ------------- Distribution ------------- count
481 262144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
484 os.py, _exists, bytes total = 362768
485 value ------------- Distribution ------------- count
494 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 447
501 The results are divided into two sections. If a malloc() occurred while in a
502 Python function, then that function is identified as responsible; and the
503 results will appear in the second section - Python malloc byte distributions
504 by Python file and function.
506 Otherwise the caller of malloc() is identified as responsible - which will be
507 a function from the Python engine, and these are noted in the first section -
508 Python malloc byte distributions by engine caller.