summaryrefslogtreecommitdiffstats
path: root/Modules/_tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-13 14:50:56 (GMT)
committerGitHub <noreply@github.com>2018-11-13 14:50:56 (GMT)
commitd57a3e5d03efdda6247c27bd682872edf399d88b (patch)
treeebe534112b37d06155291a82382ea0b0313a73e6 /Modules/_tracemalloc.c
parent55b4771d5d18d5ff7c095aa1ab750fe0c8bb5e67 (diff)
downloadcpython-d57a3e5d03efdda6247c27bd682872edf399d88b.zip
cpython-d57a3e5d03efdda6247c27bd682872edf399d88b.tar.gz
cpython-d57a3e5d03efdda6247c27bd682872edf399d88b.tar.bz2
bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10510) (GH-10517)
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.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index e07022c..7f19c55 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -1490,6 +1490,12 @@ _PyMem_DumpTraceback(int fd, const void *ptr)
traceback_t *traceback;
int i;
+ if (!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;