summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-20 15:46:36 (GMT)
committerGitHub <noreply@github.com>2017-06-20 15:46:36 (GMT)
commit5ea4c0677389ead2eee759958694cff2c65834a7 (patch)
tree90e13f3ef6da418c459de164cb7f21e9ab70a1c9 /Doc/c-api
parent26cb4657bcc9a7adffa95798ececb588dddfeadb (diff)
downloadcpython-5ea4c0677389ead2eee759958694cff2c65834a7.zip
cpython-5ea4c0677389ead2eee759958694cff2c65834a7.tar.gz
cpython-5ea4c0677389ead2eee759958694cff2c65834a7.tar.bz2
bpo-30054: Expose tracemalloc C API (#1236)
* Make PyTraceMalloc_Track() and PyTraceMalloc_Untrack() functions public (remove the "_" prefix) * Remove the _PyTraceMalloc_domain_t type: use directly unsigned int. * Document methods Note: methods are already tested in test_tracemalloc.
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/memory.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst
index 873fb2a..22b9fe2 100644
--- a/Doc/c-api/memory.rst
+++ b/Doc/c-api/memory.rst
@@ -429,6 +429,28 @@ Customize pymalloc Arena Allocator
Set the arena allocator.
+tracemalloc C API
+=================
+
+.. versionadded:: 3.7
+
+.. c:function: int PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr, size_t size)
+
+ Track an allocated memory block in the :mod:`tracemalloc` module.
+
+ Return 0 on success, return ``-1`` on error (failed to allocate memory to
+ store the trace). Return ``-2`` if tracemalloc is disabled.
+
+ If memory block is already tracked, update the existing trace.
+
+.. c:function: int PyTraceMalloc_Untrack(unsigned int domain, uintptr_t ptr)
+
+ Untrack an allocated memory block in the :mod:`tracemalloc` module.
+ Do nothing if the block was not tracked.
+
+ Return ``-2`` if tracemalloc is disabled, otherwise return ``0``.
+
+
.. _memoryexamples:
Examples