STINNER Victor added the comment: > 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); ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18203> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com