1#ifndef Py_TRACEMALLOC_H
2#define Py_TRACEMALLOC_H
3
4#ifndef Py_LIMITED_API
5/* Track an allocated memory block in the tracemalloc module.
6 Return 0 on success, return -1 on error (failed to allocate memory to store
7 the trace).
8
9 Return -2 if tracemalloc is disabled.
10
11 If memory block is already tracked, update the existing trace. */
12PyAPI_FUNC(int) PyTraceMalloc_Track(
13 unsigned int domain,
14 uintptr_t ptr,
15 size_t size);
16
17/* Untrack an allocated memory block in the tracemalloc module.
18 Do nothing if the block was not tracked.
19
20 Return -2 if tracemalloc is disabled, otherwise return 0. */
21PyAPI_FUNC(int) PyTraceMalloc_Untrack(
22 unsigned int domain,
23 uintptr_t ptr);
24
25/* Get the traceback where a memory block was allocated.
26
27 Return a tuple of (filename: str, lineno: int) tuples.
28
29 Return None if the tracemalloc module is disabled or if the memory block
30 is not tracked by tracemalloc.
31
32 Raise an exception and return NULL on error. */
33PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
34 unsigned int domain,
35 uintptr_t ptr);
36
37/* Return non-zero if tracemalloc is tracing */
38PyAPI_FUNC(int) _PyTraceMalloc_IsTracing(void);
39
40/* Clear the tracemalloc traces */
41PyAPI_FUNC(void) _PyTraceMalloc_ClearTraces(void);
42
43/* Clear the tracemalloc traces */
44PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetTraces(void);
45
46/* Clear tracemalloc traceback for an object */
47PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetObjectTraceback(PyObject *obj);
48
49/* Initialize tracemalloc */
50PyAPI_FUNC(int) _PyTraceMalloc_Init(void);
51
52/* Start tracemalloc */
53PyAPI_FUNC(int) _PyTraceMalloc_Start(int max_nframe);
54
55/* Stop tracemalloc */
56PyAPI_FUNC(void) _PyTraceMalloc_Stop(void);
57
58/* Get the tracemalloc traceback limit */
59PyAPI_FUNC(int) _PyTraceMalloc_GetTracebackLimit(void);
60
61/* Get the memory usage of tracemalloc in bytes */
62PyAPI_FUNC(size_t) _PyTraceMalloc_GetMemory(void);
63
64/* Get the current size and peak size of traced memory blocks as a 2-tuple */
65PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetTracedMemory(void);
66
67/* Set the peak size of traced memory blocks to the current size */
68PyAPI_FUNC(void) _PyTraceMalloc_ResetPeak(void);
69
70#endif
71
72#endif /* !Py_TRACEMALLOC_H */
73

source code of include/python3.12/tracemalloc.h