mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
bpo-32030: Rework memory allocators (#4625)
* Fix _PyMem_SetupAllocators("debug"): always restore allocators to the defaults, rather than only caling _PyMem_SetupDebugHooks(). * Add _PyMem_SetDefaultAllocator() helper to set the "default" allocator. * Add _PyMem_GetAllocatorsName(): get the name of the allocators * main() now uses debug hooks on memory allocators if Py_DEBUG is defined, rather than calling directly malloc() * Document default memory allocators in C API documentation * _Py_InitializeCore() now fails with a fatal user error if PYTHONMALLOC value is an unknown memory allocator, instead of failing with a fatal internal error. * Add new tests on the PYTHONMALLOC environment variable * Add support.with_pymalloc() * Add the _testcapi.WITH_PYMALLOC constant and expose it as support.with_pymalloc(). * sysconfig.get_config_var('WITH_PYMALLOC') doesn't work on Windows, so replace it with support.with_pymalloc(). * pythoninfo: add _testcapi collector for pymem
This commit is contained in:
parent
c15bb49d71
commit
5d39e04290
14 changed files with 405 additions and 171 deletions
|
@ -687,6 +687,8 @@ conflict.
|
|||
|
||||
Set the family of memory allocators used by Python:
|
||||
|
||||
* ``default``: use the :ref:`default memory allocators
|
||||
<default-memory-allocators>`.
|
||||
* ``malloc``: use the :c:func:`malloc` function of the C library
|
||||
for all domains (:c:data:`PYMEM_DOMAIN_RAW`, :c:data:`PYMEM_DOMAIN_MEM`,
|
||||
:c:data:`PYMEM_DOMAIN_OBJ`).
|
||||
|
@ -696,20 +698,17 @@ conflict.
|
|||
|
||||
Install debug hooks:
|
||||
|
||||
* ``debug``: install debug hooks on top of the default memory allocator
|
||||
* ``debug``: install debug hooks on top of the :ref:`default memory
|
||||
allocators <default-memory-allocators>`.
|
||||
* ``malloc_debug``: same as ``malloc`` but also install debug hooks
|
||||
* ``pymalloc_debug``: same as ``pymalloc`` but also install debug hooks
|
||||
|
||||
When Python is compiled in release mode, the default is ``pymalloc``. When
|
||||
compiled in debug mode, the default is ``pymalloc_debug`` and the debug hooks
|
||||
are used automatically.
|
||||
See the :ref:`default memory allocators <default-memory-allocators>` and the
|
||||
:c:func:`PyMem_SetupDebugHooks` function (install debug hooks on Python
|
||||
memory allocators).
|
||||
|
||||
If Python is configured without ``pymalloc`` support, ``pymalloc`` and
|
||||
``pymalloc_debug`` are not available, the default is ``malloc`` in release
|
||||
mode and ``malloc_debug`` in debug mode.
|
||||
|
||||
See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python
|
||||
memory allocators.
|
||||
.. versionchanged:: 3.7
|
||||
Added the ``"default"`` allocator.
|
||||
|
||||
.. versionadded:: 3.6
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue