File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ for the I/O buffer escapes completely the Python memory manager.
95
95
Allocator Domains
96
96
=================
97
97
98
+ .. _allocator-domains :
99
+
98
100
All allocating functions belong to one of three different "domains" (see also
99
101
:c:type: `PyMemAllocatorDomain `). These domains represent different allocation
100
102
strategies and are optimized for different purposes. The specific details on
@@ -477,6 +479,25 @@ Customize Memory Allocators
477
479
debug hooks on top on the new allocator.
478
480
479
481
482
+ .. warning::
483
+
484
+ :c:func:`PyMem_SetAllocator` does have the following contract:
485
+
486
+ * It can be called after :c:func:`Py_PreInitialize` and before
487
+ :c:func:`Py_InitializeFromConfig` to install a custom memory
488
+ allocator. There are no restrictions over the installed allocator
489
+ other than the ones imposed by the domain (for instance, the Raw
490
+ Domain allows the allocator to be called without the GIL held). See
491
+ :ref:`the section on allocator domains <allocator-domains>` for more
492
+ information.
493
+
494
+ * If called after Python has finish initializing (after
495
+ :c:func: `Py_InitializeFromConfig ` has been called) the allocator
496
+ **must** wrap the existing allocator. Substituting the current
497
+ allocator for some other arbitrary one is **not supported**.
498
+
499
+
500
+
480
501
.. c:function:: void PyMem_SetupDebugHooks(void)
481
502
482
503
Setup :ref:`debug hooks in the Python memory allocators <pymem-debug-hooks>`
You can’t perform that action at this time.
0 commit comments