summaryrefslogtreecommitdiffstats
path: root/Modules/clinic
diff options
context:
space:
mode:
authorHuon Wilson <wilson.huon@gmail.com>2020-06-01 17:26:22 (GMT)
committerGitHub <noreply@github.com>2020-06-01 17:26:22 (GMT)
commit3c7609a23cf6e011f2cd411e28d9dcb1b087929c (patch)
tree57e4c7324a9b926594a71db7a53830ba070eab2d /Modules/clinic
parent410b730c205133315c604350f4bdc2345588b397 (diff)
downloadcpython-3c7609a23cf6e011f2cd411e28d9dcb1b087929c.zip
cpython-3c7609a23cf6e011f2cd411e28d9dcb1b087929c.tar.gz
cpython-3c7609a23cf6e011f2cd411e28d9dcb1b087929c.tar.bz2
[3.9] bpo-40630: Add tracemalloc.reset_peak (GH-20102) (GH-20545)
* bpo-40630: Add tracemalloc.reset_peak (GH-20102, cherrypick 8b62644) The reset_peak function sets the peak memory size to the current size, representing a resetting of that metric. This allows for recording the peak of specific sections of code, ignoring other code that may have had a higher peak (since the most recent `tracemalloc.start()` or tracemalloc.clear_traces()` call). * Adjust docs to point to 3.9
Diffstat (limited to 'Modules/clinic')
-rw-r--r--Modules/clinic/_tracemalloc.c.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/Modules/clinic/_tracemalloc.c.h b/Modules/clinic/_tracemalloc.c.h
index 68fafdc..049cacd 100644
--- a/Modules/clinic/_tracemalloc.c.h
+++ b/Modules/clinic/_tracemalloc.c.h
@@ -197,4 +197,24 @@ _tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _tracemalloc_get_traced_memory_impl(module);
}
-/*[clinic end generated code: output=1bc96dc569706afa input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(_tracemalloc_reset_peak__doc__,
+"reset_peak($module, /)\n"
+"--\n"
+"\n"
+"Set the peak size of memory blocks traced by tracemalloc to the current size.\n"
+"\n"
+"Do nothing if the tracemalloc module is not tracing memory allocations.");
+
+#define _TRACEMALLOC_RESET_PEAK_METHODDEF \
+ {"reset_peak", (PyCFunction)_tracemalloc_reset_peak, METH_NOARGS, _tracemalloc_reset_peak__doc__},
+
+static PyObject *
+_tracemalloc_reset_peak_impl(PyObject *module);
+
+static PyObject *
+_tracemalloc_reset_peak(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return _tracemalloc_reset_peak_impl(module);
+}
+/*[clinic end generated code: output=a130117b1af821da input=a9049054013a1b77]*/