Message191080
> 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); |
|
Date |
User |
Action |
Args |
2013-06-13 11:32:02 | vstinner | set | recipients:
+ vstinner, amaury.forgeotdarc, ncoghlan, kristjan.jonsson, serhiy.storchaka |
2013-06-13 11:32:02 | vstinner | set | messageid: <1371123122.32.0.83474557806.issue18203@psf.upfronthosting.co.za> |
2013-06-13 11:32:02 | vstinner | link | issue18203 messages |
2013-06-13 11:32:01 | vstinner | create | |
|