blob: 206dea748be0dd0d8bf30abe6bc7a498f93a7624 [file] [log] [blame]
Serhiy Storchakab451f912017-02-04 12:18:38 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_tracemalloc_is_tracing__doc__,
6"is_tracing($module, /)\n"
7"--\n"
8"\n"
Serhiy Storchaka97353842017-02-05 22:58:46 +02009"Return True if the tracemalloc module is tracing Python memory allocations.");
Serhiy Storchakab451f912017-02-04 12:18:38 +020010
11#define _TRACEMALLOC_IS_TRACING_METHODDEF \
12 {"is_tracing", (PyCFunction)_tracemalloc_is_tracing, METH_NOARGS, _tracemalloc_is_tracing__doc__},
13
14static PyObject *
15_tracemalloc_is_tracing_impl(PyObject *module);
16
17static PyObject *
18_tracemalloc_is_tracing(PyObject *module, PyObject *Py_UNUSED(ignored))
19{
20 return _tracemalloc_is_tracing_impl(module);
21}
22
23PyDoc_STRVAR(_tracemalloc_clear_traces__doc__,
24"clear_traces($module, /)\n"
25"--\n"
26"\n"
27"Clear traces of memory blocks allocated by Python.");
28
29#define _TRACEMALLOC_CLEAR_TRACES_METHODDEF \
30 {"clear_traces", (PyCFunction)_tracemalloc_clear_traces, METH_NOARGS, _tracemalloc_clear_traces__doc__},
31
32static PyObject *
33_tracemalloc_clear_traces_impl(PyObject *module);
34
35static PyObject *
36_tracemalloc_clear_traces(PyObject *module, PyObject *Py_UNUSED(ignored))
37{
38 return _tracemalloc_clear_traces_impl(module);
39}
40
41PyDoc_STRVAR(_tracemalloc__get_traces__doc__,
42"_get_traces($module, /)\n"
43"--\n"
44"\n"
45"Get traces of all memory blocks allocated by Python.\n"
46"\n"
47"Return a list of (size: int, traceback: tuple) tuples.\n"
48"traceback is a tuple of (filename: str, lineno: int) tuples.\n"
49"\n"
50"Return an empty list if the tracemalloc module is disabled.");
51
52#define _TRACEMALLOC__GET_TRACES_METHODDEF \
53 {"_get_traces", (PyCFunction)_tracemalloc__get_traces, METH_NOARGS, _tracemalloc__get_traces__doc__},
54
55static PyObject *
56_tracemalloc__get_traces_impl(PyObject *module);
57
58static PyObject *
59_tracemalloc__get_traces(PyObject *module, PyObject *Py_UNUSED(ignored))
60{
61 return _tracemalloc__get_traces_impl(module);
62}
63
64PyDoc_STRVAR(_tracemalloc__get_object_traceback__doc__,
65"_get_object_traceback($module, obj, /)\n"
66"--\n"
67"\n"
68"Get the traceback where the Python object obj was allocated.\n"
69"\n"
70"Return a tuple of (filename: str, lineno: int) tuples.\n"
71"Return None if the tracemalloc module is disabled or did not\n"
72"trace the allocation of the object.");
73
74#define _TRACEMALLOC__GET_OBJECT_TRACEBACK_METHODDEF \
75 {"_get_object_traceback", (PyCFunction)_tracemalloc__get_object_traceback, METH_O, _tracemalloc__get_object_traceback__doc__},
76
77PyDoc_STRVAR(_tracemalloc_start__doc__,
78"start($module, nframe=1, /)\n"
79"--\n"
80"\n"
81"Start tracing Python memory allocations.\n"
82"\n"
83"Also set the maximum number of frames stored in the traceback of a\n"
84"trace to nframe.");
85
86#define _TRACEMALLOC_START_METHODDEF \
87 {"start", (PyCFunction)_tracemalloc_start, METH_FASTCALL, _tracemalloc_start__doc__},
88
89static PyObject *
Victor Stinnera7368ac2017-11-15 18:11:45 -080090_tracemalloc_start_impl(PyObject *module, int nframe);
Serhiy Storchakab451f912017-02-04 12:18:38 +020091
92static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030093_tracemalloc_start(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchakab451f912017-02-04 12:18:38 +020094{
95 PyObject *return_value = NULL;
Victor Stinnera7368ac2017-11-15 18:11:45 -080096 int nframe = 1;
Serhiy Storchakab451f912017-02-04 12:18:38 +020097
Victor Stinnera7368ac2017-11-15 18:11:45 -080098 if (!_PyArg_ParseStack(args, nargs, "|i:start",
Sylvain74453812017-06-10 06:51:48 +020099 &nframe)) {
Serhiy Storchakab451f912017-02-04 12:18:38 +0200100 goto exit;
101 }
102 return_value = _tracemalloc_start_impl(module, nframe);
103
104exit:
105 return return_value;
106}
107
108PyDoc_STRVAR(_tracemalloc_stop__doc__,
109"stop($module, /)\n"
110"--\n"
111"\n"
112"Stop tracing Python memory allocations.\n"
113"\n"
114"Also clear traces of memory blocks allocated by Python.");
115
116#define _TRACEMALLOC_STOP_METHODDEF \
117 {"stop", (PyCFunction)_tracemalloc_stop, METH_NOARGS, _tracemalloc_stop__doc__},
118
119static PyObject *
120_tracemalloc_stop_impl(PyObject *module);
121
122static PyObject *
123_tracemalloc_stop(PyObject *module, PyObject *Py_UNUSED(ignored))
124{
125 return _tracemalloc_stop_impl(module);
126}
127
128PyDoc_STRVAR(_tracemalloc_get_traceback_limit__doc__,
129"get_traceback_limit($module, /)\n"
130"--\n"
131"\n"
132"Get the maximum number of frames stored in the traceback of a trace.\n"
133"\n"
134"By default, a trace of an allocated memory block only stores\n"
135"the most recent frame: the limit is 1.");
136
137#define _TRACEMALLOC_GET_TRACEBACK_LIMIT_METHODDEF \
138 {"get_traceback_limit", (PyCFunction)_tracemalloc_get_traceback_limit, METH_NOARGS, _tracemalloc_get_traceback_limit__doc__},
139
140static PyObject *
141_tracemalloc_get_traceback_limit_impl(PyObject *module);
142
143static PyObject *
144_tracemalloc_get_traceback_limit(PyObject *module, PyObject *Py_UNUSED(ignored))
145{
146 return _tracemalloc_get_traceback_limit_impl(module);
147}
148
149PyDoc_STRVAR(_tracemalloc_get_tracemalloc_memory__doc__,
150"get_tracemalloc_memory($module, /)\n"
151"--\n"
152"\n"
153"Get the memory usage in bytes of the tracemalloc module.\n"
154"\n"
155"This memory is used internally to trace memory allocations.");
156
157#define _TRACEMALLOC_GET_TRACEMALLOC_MEMORY_METHODDEF \
158 {"get_tracemalloc_memory", (PyCFunction)_tracemalloc_get_tracemalloc_memory, METH_NOARGS, _tracemalloc_get_tracemalloc_memory__doc__},
159
160static PyObject *
161_tracemalloc_get_tracemalloc_memory_impl(PyObject *module);
162
163static PyObject *
164_tracemalloc_get_tracemalloc_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
165{
166 return _tracemalloc_get_tracemalloc_memory_impl(module);
167}
168
169PyDoc_STRVAR(_tracemalloc_get_traced_memory__doc__,
170"get_traced_memory($module, /)\n"
171"--\n"
172"\n"
173"Get the current size and peak size of memory blocks traced by tracemalloc.\n"
174"\n"
175"Returns a tuple: (current: int, peak: int).");
176
177#define _TRACEMALLOC_GET_TRACED_MEMORY_METHODDEF \
178 {"get_traced_memory", (PyCFunction)_tracemalloc_get_traced_memory, METH_NOARGS, _tracemalloc_get_traced_memory__doc__},
179
180static PyObject *
181_tracemalloc_get_traced_memory_impl(PyObject *module);
182
183static PyObject *
184_tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
185{
186 return _tracemalloc_get_traced_memory_impl(module);
187}
Victor Stinnera7368ac2017-11-15 18:11:45 -0800188/*[clinic end generated code: output=db4f909464c186e2 input=a9049054013a1b77]*/