Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:51

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