|
10 | 10 | prints the repr() of each object while the interpreter is still fully intact. |
11 | 11 | After cleaning up everything it can, it prints all remaining live objects |
12 | 12 | again, but the second time just prints their addresses, refcounts, and type |
13 | | -names. |
| 13 | +names (because the interpreter has been torn down, calling repr methods at |
| 14 | +this point can get into infinite loops or blow up). |
14 | 15 |
|
15 | 16 | Save all this output into a file, then run this script passing the path to |
16 | 17 | that file. The script finds both output chunks, combines them, then prints |
|
36 | 37 | output block. |
37 | 38 |
|
38 | 39 | repr is repr(object), extracted from the first PYTHONDUMPREFS output block. |
| 40 | +CAUTION: If object is a container type, it may not actually contain all the |
| 41 | +objects shown in the repr: the repr was captured from the first output block, |
| 42 | +and some of the containees may have been released since then. For example, |
| 43 | +it's common for the line showing the dict of interned strings to display |
| 44 | +strings that no longer exist at the end of Py_Finalize; this can be recognized |
| 45 | +(albeit painfully) because such containees don't have a line of their own. |
39 | 46 |
|
40 | 47 | The objects are listed in allocation order, with most-recently allocated |
41 | 48 | printed first, and the first object allocated printed last. |
|
57 | 64 |
|
58 | 65 | 00858028 [1025->1456] str '<dummy key>' |
59 | 66 |
|
60 | | -The string '<dummy key>', which is used in dictobject.c as the name of the |
61 | | -dummy key that overwrites a real key that gets deleted, actually grew |
62 | | -several hundred references during cleanup. It suggests that stuff did get |
63 | | -removed from dicts by cleanup, but that the dicts themselves are staying |
64 | | -alive for some reason. |
65 | | -""" |
| 67 | +The string '<dummy key>', which is used in dictobject.c to overwrite a real |
| 68 | +key that gets deleted, grew several hundred references during cleanup. It |
| 69 | +suggests that stuff did get removed from dicts by cleanup, but that the dicts |
| 70 | +themselves are staying alive for some reason. """ |
66 | 71 |
|
67 | 72 | import re |
68 | 73 | import sys |
|
0 commit comments