cpython: 66db0c66a6ee (original) (raw)

Mercurial > cpython

changeset 87402:66db0c66a6ee

Issue #18874: Remove tracemalloc.set_traceback_limit() tracemalloc.start() now has an option nframe parameter [#18874]

Victor Stinner victor.stinner@gmail.com
date Sat, 23 Nov 2013 12:37:20 +0100
parents 6e2089dbc5ad
children 2e3bee6e682b
files Doc/library/tracemalloc.rst Doc/using/cmdline.rst Lib/test/test_tracemalloc.py Modules/_tracemalloc.c
diffstat 4 files changed, 52 insertions(+), 72 deletions(-)[+] [-] Doc/library/tracemalloc.rst 36 Doc/using/cmdline.rst 18 Lib/test/test_tracemalloc.py 21 Modules/_tracemalloc.c 49

line wrap: on

line diff

--- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -21,8 +21,7 @@ start tracing Python memory allocations. By default, a trace of an allocated memory block only stores the most recent frame (1 frame). To store 25 frames at startup: set the :envvar:PYTHONTRACEMALLOC environment variable to 25, or use the -:option:-X tracemalloc=25 command line option. The -:func:set_traceback_limit function can be used at runtime to set the limit. +:option:-X tracemalloc=25 command line option. .. versionadded:: 3.4 @@ -120,8 +119,8 @@ Code to display the traceback of the big import linecache import tracemalloc

# ... run your application ... @@ -267,10 +266,10 @@ Functions Get the maximum number of frames stored in the traceback of a trace.

.. function:: get_traced_memory() @@ -294,10 +293,12 @@ Functions See also :func:start and :func:stop functions. -.. function:: set_traceback_limit(nframe: int) +.. function:: start(nframe: int=1)

-.. function:: start() -

.. function:: stop() @@ -342,7 +336,7 @@ Functions :mod:tracemalloc module started to trace memory allocations. Tracebacks of traces are limited to :func:get_traceback_limit frames. Use

--- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -381,10 +381,11 @@ Miscellaneous options * -X faulthandler to enable :mod:faulthandler; * -X showrefcount to enable the output of the total reference count and memory blocks (only works on debug builds);

It also allows to pass arbitrary values and retrieve them through the :data:sys._xoptions dictionary. @@ -600,10 +601,11 @@ conflict. .. envvar:: PYTHONTRACEMALLOC

--- a/Lib/test/test_tracemalloc.py +++ b/Lib/test/test_tracemalloc.py @@ -83,8 +83,7 @@ class TestTracemallocEnabled(unittest.Te if tracemalloc.is_tracing(): self.skipTest("tracemalloc must be stopped before the test")

def tearDown(self): tracemalloc.stop() @@ -109,20 +108,18 @@ class TestTracemallocEnabled(unittest.Te def test_set_traceback_limit(self): obj_size = 10

-

@@ -163,8 +160,8 @@ class TestTracemallocEnabled(unittest.Te return allocate_bytes3(size) # Ensure that two identical tracebacks are not duplicated

--- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -1151,13 +1151,27 @@ done: } PyDoc_STRVAR(tracemalloc_start_doc,

static PyObject* -py_tracemalloc_start(PyObject *self) +py_tracemalloc_start(PyObject *self, PyObject *args) {

+

+

+ if (tracemalloc_start() < 0) return NULL; @@ -1192,31 +1206,6 @@ py_tracemalloc_get_traceback_limit(PyObj return PyLong_FromLong(tracemalloc_config.max_nframe); } -PyDoc_STRVAR(tracemalloc_set_traceback_limit_doc,

- -static PyObject* -tracemalloc_set_traceback_limit(PyObject *self, PyObject *args) -{

-

-

-

-} - PyDoc_STRVAR(tracemalloc_get_tracemalloc_memory_doc, "get_tracemalloc_memory() -> int\n" "\n" @@ -1275,13 +1264,11 @@ static PyMethodDef module_methods[] = { {"_get_object_traceback", (PyCFunction)py_tracemalloc_get_object_traceback, METH_O, tracemalloc_get_object_traceback_doc}, {"start", (PyCFunction)py_tracemalloc_start,