Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 28653:56006d97bcef legacy-trunk
_Py_PrintReferences(): Changed to print object address at start of each
new line.
New pvt API function _Py_PrintReferenceAddresses(): Prints only the
addresses and refcnts of the live objects. This is always safe to call,
because it has no dependence on Python's C API.
Py_Finalize(): If envar PYTHONDUMPREFS is set, call (the new)
_Py_PrintReferenceAddresses() right before dumping final pymalloc stats.
We can't print the reprs of the objects here because too much of the
interpreter has been shut down. You need to correlate the addresses
displayed here with the object reprs printed by the earlier
PYTHONDUMPREFS call to _Py_PrintReferences().
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Thu, 17 Apr 2003 19:52:29 +0000 |
| parents | 7fda09f751ad |
| children | a4154dd5939a |
comparison
equal
deleted
inserted
replaced
| 28652:28a2975514cd | 28653:56006d97bcef |
|---|---|
| 282 /* Display all objects still alive -- this can invoke arbitrary | 282 /* Display all objects still alive -- this can invoke arbitrary |
| 283 * __repr__ overrides, so requires a mostly-intact interpreter. | 283 * __repr__ overrides, so requires a mostly-intact interpreter. |
| 284 * Alas, a lot of stuff may still be alive now that will be cleaned | 284 * Alas, a lot of stuff may still be alive now that will be cleaned |
| 285 * up later. | 285 * up later. |
| 286 */ | 286 */ |
| 287 if (Py_GETENV("PYTHONDUMPREFS")) { | 287 if (Py_GETENV("PYTHONDUMPREFS")) |
| 288 _Py_PrintReferences(stderr); | 288 _Py_PrintReferences(stderr); |
| 289 } | |
| 290 #endif /* Py_TRACE_REFS */ | 289 #endif /* Py_TRACE_REFS */ |
| 291 | 290 |
| 292 /* Now we decref the exception classes. After this point nothing | 291 /* Now we decref the exception classes. After this point nothing |
| 293 can raise an exception. That's okay, because each Fini() method | 292 can raise an exception. That's okay, because each Fini() method |
| 294 below has been checked to make sure no exceptions are ever | 293 below has been checked to make sure no exceptions are ever |
| 323 - whatever various modules and libraries allocate | 322 - whatever various modules and libraries allocate |
| 324 */ | 323 */ |
| 325 | 324 |
| 326 PyGrammar_RemoveAccelerators(&_PyParser_Grammar); | 325 PyGrammar_RemoveAccelerators(&_PyParser_Grammar); |
| 327 | 326 |
| 327 #ifdef Py_TRACE_REFS | |
| 328 /* Display addresses (& refcnts) of all objects still alive. | |
| 329 * An address can be used to find the repr of the object, printed | |
| 330 * above by _Py_PrintReferences. | |
| 331 */ | |
| 332 if (Py_GETENV("PYTHONDUMPREFS")) | |
| 333 _Py_PrintReferenceAddresses(stderr); | |
| 334 #endif /* Py_TRACE_REFS */ | |
| 328 #ifdef PYMALLOC_DEBUG | 335 #ifdef PYMALLOC_DEBUG |
| 329 if (Py_GETENV("PYTHONMALLOCSTATS")) | 336 if (Py_GETENV("PYTHONMALLOCSTATS")) |
| 330 _PyObject_DebugMallocStats(); | 337 _PyObject_DebugMallocStats(); |
| 331 #endif | 338 #endif |
| 332 | 339 |
