mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
gh-112529: Track if debug allocator is used as underlying allocator (#113747)
* gh-112529: Track if debug allocator is used as underlying allocator The GC implementation for free-threaded builds will need to accurately detect if the debug allocator is used because it affects the offset of the Python object from the beginning of the memory allocation. The current implementation of `_PyMem_DebugEnabled` only considers if the debug allocator is the outer-most allocator; it doesn't handle the case of "hooks" like tracemalloc being used on top of the debug allocator. This change enables more accurate detection of the debug allocator by tracking when debug hooks are enabled. * Simplify _PyMem_DebugEnabled
This commit is contained in:
parent
c86571e4c9
commit
b331381485
4 changed files with 21 additions and 6 deletions
|
|
@ -44,6 +44,7 @@ struct _pymem_allocators {
|
|||
debug_alloc_api_t mem;
|
||||
debug_alloc_api_t obj;
|
||||
} debug;
|
||||
int is_debug_enabled;
|
||||
PyObjectArenaAllocator obj_arena;
|
||||
};
|
||||
|
||||
|
|
@ -106,6 +107,8 @@ extern int _PyMem_GetAllocatorName(
|
|||
PYMEM_ALLOCATOR_NOT_SET does nothing. */
|
||||
extern int _PyMem_SetupAllocators(PyMemAllocatorName allocator);
|
||||
|
||||
/* Is the debug allocator enabled? */
|
||||
extern int _PyMem_DebugEnabled(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue