[New-bugs-announce] [issue18227] Use Python memory allocators in external libraries like zlib or OpenSSL
report at bugs.python.org
Sun Jun 16 01:27:49 CEST 2013
New submission from STINNER Victor:
With the PEP 445 and the issue #3329, Python will get an API to setup custom memory allocators. To be able to configure how memory is handled in external libraries, some libraries allow to setup a custom allocator too. New functions PyMem_RawMalloc(), PyMem_GetRawAllocators() PyMem_SetRawAllocators() can be used for that.
The safest option is to only reuse custom allocators if a library allows to setup them for a specfic function call or a specific object, and not replace the memory allocators globally. For example, the lzma library allows to set memory allocators only for one compressor object: LzmaEnc_Create(&SzAllocForLzma);
We might change the global allocators of a library if Python is not embedded, but Python *is* the application (the standard "python" program).
I don't know yet if it is safe to reuse custom memory allocators.
Windows has for example a special behaviour: each DLL (dynamic library) has its own heap, memory allocator in a DLL cannot be released from another DLL. Would this issue introduce such bug?
components: Interpreter Core
nosy: christian.heimes, haypo
title: Use Python memory allocators in external libraries like zlib or OpenSSL
versions: Python 3.4
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce