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 <1371123122.32.0.83474557806.issue18203@psf.upfronthosting.co.za>
In-reply-to
Content
> 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, http://www.zlib.net/manual.html#Usage
- 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;
    mpd_setminalloc(_Py_DEC_MINALLOC);
History
Date User Action Args
2013-06-13 11:32:02vstinnersetrecipients: + vstinner, amaury.forgeotdarc, ncoghlan, kristjan.jonsson, serhiy.storchaka
2013-06-13 11:32:02vstinnersetmessageid: <1371123122.32.0.83474557806.issue18203@psf.upfronthosting.co.za>
2013-06-13 11:32:02vstinnerlinkissue18203 messages
2013-06-13 11:32:01vstinnercreate