diff options
| author | Victor Stinner <vstinner@redhat.com> | 2018-11-13 14:14:58 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-13 14:14:58 (GMT) |
| commit | f966e5397ed8f5c42c185223fc9b4d750a678d02 (patch) | |
| tree | f5cb478c7f28e95c498c46678c43864c499cfa24 /Modules/_tracemalloc.c | |
| parent | 474eedfb3d1b6fecbd749f36bf4a987cf4a00b44 (diff) | |
| download | cpython-f966e5397ed8f5c42c185223fc9b4d750a678d02.zip cpython-f966e5397ed8f5c42c185223fc9b4d750a678d02.tar.gz cpython-f966e5397ed8f5c42c185223fc9b4d750a678d02.tar.bz2 | |
bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10510)
If tracemalloc is not tracing Python memory allocations,
_PyMem_DumpTraceback() now suggests to enable tracemalloc
to get the traceback where the memory block has been allocated.
Diffstat (limited to 'Modules/_tracemalloc.c')
| -rw-r--r-- | Modules/_tracemalloc.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index 1005f2e..c5d5671 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -1471,6 +1471,12 @@ _PyMem_DumpTraceback(int fd, const void *ptr) traceback_t *traceback; int i; + if (!_Py_tracemalloc_config.tracing) { + PUTS(fd, "Enable tracemalloc to get the memory block " + "allocation traceback\n\n"); + return; + } + traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (uintptr_t)ptr); if (traceback == NULL) return; |
