Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 77577:d63a80abfbec
Issue #14785: Add sys._debugmallocstats() to help debug low-level memory allocation issues
| author | David Malcolm <dmalcolm@redhat.com> |
|---|---|
| date | Fri, 22 Jun 2012 14:55:41 -0400 |
| parents | 9c445f4695c1 |
| children | ee01fd98b5b0 |
line wrap: on
line diff
--- a/Python/sysmodule.c Fri Jun 22 18:40:02 2012 +0000 +++ b/Python/sysmodule.c Fri Jun 22 14:55:41 2012 -0400 @@ -997,6 +997,27 @@ extern "C" { #endif +static PyObject * +sys_debugmallocstats(PyObject *self, PyObject *args) +{ +#ifdef WITH_PYMALLOC + _PyObject_DebugMallocStats(stderr); + fputc('\n', stderr); +#endif + _PyObject_DebugTypeStats(stderr); + + Py_RETURN_NONE; +} +PyDoc_STRVAR(debugmallocstats_doc, +"_debugmallocstats()\n\ +\n\ +Print summary info to stderr about the state of\n\ +pymalloc's structures.\n\ +\n\ +In Py_DEBUG mode, also perform some expensive internal consistency\n\ +checks.\n\ +"); + #ifdef Py_TRACE_REFS /* Defined in objects.c because it uses static globals if that file */ extern PyObject *_Py_GetObjects(PyObject *, PyObject *); @@ -1093,6 +1114,8 @@ {"settrace", sys_settrace, METH_O, settrace_doc}, {"gettrace", sys_gettrace, METH_NOARGS, gettrace_doc}, {"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc}, + {"_debugmallocstats", sys_debugmallocstats, METH_VARARGS, + debugmallocstats_doc}, {NULL, NULL} /* sentinel */ };
