Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:04:07

0001 #ifndef Py_TRACEMALLOC_H
0002 #define Py_TRACEMALLOC_H
0003 #ifndef Py_LIMITED_API
0004 #ifdef __cplusplus
0005 extern "C" {
0006 #endif
0007 
0008 /* Track an allocated memory block in the tracemalloc module.
0009    Return 0 on success, return -1 on error (failed to allocate memory to store
0010    the trace).
0011 
0012    Return -2 if tracemalloc is disabled.
0013 
0014    If memory block is already tracked, update the existing trace. */
0015 PyAPI_FUNC(int) PyTraceMalloc_Track(
0016     unsigned int domain,
0017     uintptr_t ptr,
0018     size_t size);
0019 
0020 /* Untrack an allocated memory block in the tracemalloc module.
0021    Do nothing if the block was not tracked.
0022 
0023    Return -2 if tracemalloc is disabled, otherwise return 0. */
0024 PyAPI_FUNC(int) PyTraceMalloc_Untrack(
0025     unsigned int domain,
0026     uintptr_t ptr);
0027 
0028 /* Get the traceback where a memory block was allocated.
0029 
0030    Return a tuple of (filename: str, lineno: int) tuples.
0031 
0032    Return None if the tracemalloc module is disabled or if the memory block
0033    is not tracked by tracemalloc.
0034 
0035    Raise an exception and return NULL on error. */
0036 PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
0037     unsigned int domain,
0038     uintptr_t ptr);
0039 
0040 /* Return non-zero if tracemalloc is tracing */
0041 PyAPI_FUNC(int) _PyTraceMalloc_IsTracing(void);
0042 
0043 /* Clear the tracemalloc traces */
0044 PyAPI_FUNC(void) _PyTraceMalloc_ClearTraces(void);
0045 
0046 /* Clear the tracemalloc traces */
0047 PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetTraces(void);
0048 
0049 /* Clear tracemalloc traceback for an object */
0050 PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetObjectTraceback(PyObject *obj);
0051 
0052 /* Initialize tracemalloc */
0053 PyAPI_FUNC(PyStatus) _PyTraceMalloc_Init(void);
0054 
0055 /* Start tracemalloc */
0056 PyAPI_FUNC(int) _PyTraceMalloc_Start(int max_nframe);
0057 
0058 /* Stop tracemalloc */
0059 PyAPI_FUNC(void) _PyTraceMalloc_Stop(void);
0060 
0061 /* Get the tracemalloc traceback limit */
0062 PyAPI_FUNC(int) _PyTraceMalloc_GetTracebackLimit(void);
0063 
0064 /* Get the memory usage of tracemalloc in bytes */
0065 PyAPI_FUNC(size_t) _PyTraceMalloc_GetMemory(void);
0066 
0067 /* Get the current size and peak size of traced memory blocks as a 2-tuple */
0068 PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetTracedMemory(void);
0069 
0070 /* Set the peak size of traced memory blocks to the current size */
0071 PyAPI_FUNC(void) _PyTraceMalloc_ResetPeak(void);
0072 
0073 #ifdef __cplusplus
0074 }
0075 #endif
0076 #endif /* !Py_LIMITED_API */
0077 #endif /* !Py_TRACEMALLOC_H */