xref: /third_party/python/Include/tracemalloc.h (revision 7db96d56)
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#endif
37
38#endif /* !Py_TRACEMALLOC_H */
39