tracemalloc.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef Py_TRACEMALLOC_H
  2. #define Py_TRACEMALLOC_H
  3. #ifndef Py_LIMITED_API
  4. /* Track an allocated memory block in the tracemalloc module.
  5. Return 0 on success, return -1 on error (failed to allocate memory to store
  6. the trace).
  7. Return -2 if tracemalloc is disabled.
  8. If memory block is already tracked, update the existing trace. */
  9. PyAPI_FUNC(int) PyTraceMalloc_Track(
  10. unsigned int domain,
  11. uintptr_t ptr,
  12. size_t size);
  13. /* Untrack an allocated memory block in the tracemalloc module.
  14. Do nothing if the block was not tracked.
  15. Return -2 if tracemalloc is disabled, otherwise return 0. */
  16. PyAPI_FUNC(int) PyTraceMalloc_Untrack(
  17. unsigned int domain,
  18. uintptr_t ptr);
  19. /* Get the traceback where a memory block was allocated.
  20. Return a tuple of (filename: str, lineno: int) tuples.
  21. Return None if the tracemalloc module is disabled or if the memory block
  22. is not tracked by tracemalloc.
  23. Raise an exception and return NULL on error. */
  24. PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
  25. unsigned int domain,
  26. uintptr_t ptr);
  27. #endif
  28. #endif /* !Py_TRACEMALLOC_H */