Add PYTHONMALLOC env var

Issue #26516:

* Add PYTHONMALLOC environment variable to set the Python memory
  allocators and/or install debug hooks.
* PyMem_SetupDebugHooks() can now also be used on Python compiled in release
  mode.
* The PYTHONMALLOCSTATS environment variable can now also be used on Python
  compiled in release mode. It now has no effect if set to an empty string.
* In debug mode, debug hooks are now also installed on Python memory allocators
  when Python is configured without pymalloc.
This commit is contained in:
Victor Stinner 2016-03-14 12:04:26 +01:00
parent c877658d1f
commit 34be807ca4
13 changed files with 383 additions and 90 deletions

View file

@ -1151,8 +1151,10 @@ static PyObject *
sys_debugmallocstats(PyObject *self, PyObject *args)
{
#ifdef WITH_PYMALLOC
_PyObject_DebugMallocStats(stderr);
fputc('\n', stderr);
if (_PyMem_PymallocEnabled()) {
_PyObject_DebugMallocStats(stderr);
fputc('\n', stderr);
}
#endif
_PyObject_DebugTypeStats(stderr);