summaryrefslogtreecommitdiff
path: root/Modules/_tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-13 16:13:17 +0100
committerGitHub <noreply@github.com>2018-11-13 16:13:17 +0100
commitae8878176d6dc1878d1e792ac4308ca1920b103b (patch)
tree5fc0f2bd9731d652a5ab136d120f4966499a0ffe /Modules/_tracemalloc.c
parent60a6baef4005a32fb4cf45e15942ea18e59ecf19 (diff)
downloadcpython-git-ae8878176d6dc1878d1e792ac4308ca1920b103b.tar.gz
bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10510) (GH-10518)
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 4f3bb5463f..a61bdb62fb 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -1492,6 +1492,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;