mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
PyMem_Malloc() now uses the fast pymalloc allocator
Issue #26249: PyMem_Malloc() allocator family now uses the pymalloc allocator rather than system malloc(). Applications calling PyMem_Malloc() without holding the GIL can now crash: use PYTHONMALLOC=debug environment variable to validate the usage of memory allocators in your application.
This commit is contained in:
parent
5439fc4901
commit
f5c4b99034
5 changed files with 58 additions and 32 deletions
|
|
@ -198,9 +198,9 @@ static PyMemAllocatorEx _PyMem_Raw = {
|
|||
|
||||
static PyMemAllocatorEx _PyMem = {
|
||||
#ifdef Py_DEBUG
|
||||
&_PyMem_Debug.mem, PYDBG_FUNCS
|
||||
&_PyMem_Debug.obj, PYDBG_FUNCS
|
||||
#else
|
||||
NULL, PYMEM_FUNCS
|
||||
NULL, PYOBJ_FUNCS
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ _PyMem_SetupAllocators(const char *opt)
|
|||
PyMemAllocatorEx obj_alloc = {NULL, PYOBJ_FUNCS};
|
||||
|
||||
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &mem_alloc);
|
||||
PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &mem_alloc);
|
||||
PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &obj_alloc);
|
||||
PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &obj_alloc);
|
||||
|
||||
if (strcmp(opt, "pymalloc_debug") == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue