This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, kristjan.jonsson, ncoghlan, serhiy.storchaka, vstinner
Date 2013-06-13.11:32:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Be aware about external code which allocate memory itself (i.e. expat).

Well, I know that it will hard to cover 100% of the stdlib. I just want to replace the most obvious calls.

Some libraries can be configured to use a custom memory allocators:

- zlib: zalloc and zfree,
- bz2
- lzma: LzmaEnc_Create parameter
- OpenSSL: CRYPTO_set_mem_functions
- etc.

We should probably uses these functions to reuse Python allocators (PyMem_Malloc()), or maybe only if PyMem_SetAllocators() has been called? (if Python does not use system allocators, aka malloc)

See also #18178 for libffi, it may be related.

The _decimal module configures libmpdec to use PyMem_Malloc:

#define _Py_DEC_MINALLOC 4

    mpd_mallocfunc = PyMem_Malloc;
    mpd_reallocfunc = PyMem_Realloc;
    mpd_callocfunc = mpd_callocfunc_em;
    mpd_free = PyMem_Free;
Date User Action Args
2013-06-13 11:32:02vstinnersetrecipients: + vstinner, amaury.forgeotdarc, ncoghlan, kristjan.jonsson, serhiy.storchaka
2013-06-13 11:32:02vstinnersetmessageid: <>
2013-06-13 11:32:02vstinnerlinkissue18203 messages
2013-06-13 11:32:01vstinnercreate